Feeds

Beginning Hibernate

More object relational mapping

High performance access to file storage

Book review Although it sounds like something to do with electrical resistance in AC circuits, "impedance mismatch" describes the issues that arise when dealing with the different conceptual bases of object oriented development and relational databases.

Developers model their domain with classes and objects, but when it comes to persisting these objects there's usually a relational database as the data store – which means having to stuff those nice object hierarchies into relational tables.

For very small applications, hand-coding provides an answer – a bit of SQL and some code can work wonders. Anything bigger requires an object-relational mapping (ORM) layer to bundle objects into and out of those relational tables.

While there's a certain satisfaction in rolling your own ORM layer, the fact is that there are plenty of powerful open-source ORM frameworks, and in the Java world, at least, Hibernate is one of the best known and most widely used.

Hibernate provides a complete persistence and query framework – basically you can code your application using plain old Java objects (POJOs), and then use Hibernate to marshal your objects, persist them to a back-end database of your choice, apply queries to the data, retrieve and instantiate the object tree and so on. It requires minimal change to your existing code, but does depend on building a suitable mapping from objects to tables and fields.

However, Hibernate isn't magic, there are configuration files to create, mappings to perform, and other bits of plumbing in order to make things work as seamlessly as you would like. Hence Beginning Hibernate by Dave Minter and Jeff Linwood, which aims to help the new user to get up, running, and productive quickly.

Unfortunately, setting up Hibernate is not simply a drag and drop affair – there are too many variables and dependencies involved in mapping from objects to databases. Some of these are explored in the opening chapter, including the relationship between Hibernate and the more traditional JEE use of enterprise Java beans (EJB) for persistence, and also touches on the latest EJB 3.0 release, which has incorporated some of the features of Hibernate.

The second chapter, covering integration and configuration, looks at the different ways of creating the mapping between Java objects and the underlying database. The advantages and disadvantages of properties files, XML files and Java annotations are all explored.

It's only in chapter three that the first sample application is built – although it feels like over-kill in that it uses Hibernate, the Hibernate tools, Ant, the HSQLDB database and logging. On the plus side, it's a realistic example of what you'd need to do in a real application. The downside is that it's fairly complex for a first look at Hibernate in action.

From then on the material gets more focused, and covers in greater detail the intricacies of mapping (both with XML and with the newer annotations), the use of the HQL query language, the filtering of search results, transactions, and the session object. Appendices include coverage of the advanced features (stored procedures, events and more), the Hibernate tools (Eclipse plug-in and Ant tasks), Hibernate and Spring also gets an appendix chapter, as does the process of upgrading from version 2.x to the latest 3.2 version.

While this is a book that's clearly designed for the Hibernate beginner, it's not for the Java beginner. The content is focused, technical, and heavy on the sample Java and XML code.

Beginning Hibernate

Beginning Hibernate

Verdict: It's not a light read, but then this isn't a topic that makes for light reading in the first place.

Author: Dave Minter and Jeff Linwood

Publisher: Apress

ISBN: 1590596935

Media: Book

List Price: £27.99

Buy this book at Register Books at Reg Developer's special discounted price! ®

Combat fraud and increase customer satisfaction

More from The Register

next story
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Oh no, Joe: WinPhone users already griping over 8.1 mega-update
Hang on. Which bit of Developer Preview don't you understand?
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
Ditch the sync, paddle in the Streem: Upstart offers syncless sharing
Upload, delete and carry on sharing afterwards?
New Facebook phone app allows you to stalk your mates
Nearby Friends feature goes live in a few weeks
Microsoft TIER SMEAR changes app prices whether devs ask or not
Some go up, some go down, Redmond goes silent
Batten down the hatches, Ubuntu 14.04 LTS due in TWO DAYS
Admins dab straining server brows in advance of Trusty Tahr's long-term support landing
prev story

Whitepapers

SANS - Survey on application security programs
In this whitepaper learn about the state of application security programs and practices of 488 surveyed respondents, and discover how mature and effective these programs are.
Combat fraud and increase customer satisfaction
Based on their experience using HP ArcSight Enterprise Security Manager for IT security operations, Finansbank moved to HP ArcSight ESM for fraud management.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Top three mobile application threats
Learn about three of the top mobile application security threats facing businesses today and recommendations on how to mitigate the risk.
3 Big data security analytics techniques
Applying these Big Data security analytics techniques can help you make your business safer by detecting attacks early, before significant damage is done.