Feeds

Beginning Hibernate

More object relational mapping

The essential guide to IT transformation

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! ®

Boost IT visibility and business value

More from The Register

next story
Munich considers dumping Linux for ... GULP ... Windows!
Give a penguinista a hug, the Outlook's not good for open source's poster child
The Return of BSOD: Does ANYONE trust Microsoft patches?
Sysadmins, you're either fighting fires or seen as incompetents now
Intel's Raspberry Pi rival Galileo can now run Windows
Behold the Internet of Things. Wintel Things
Microsoft cries UNINSTALL in the wake of Blue Screens of Death™
Cache crash causes contained choloric calamity
Eat up Martha! Microsoft slings handwriting recog into OneNote on Android
Freehand input on non-Windows kit for the first time
Time to move away from Windows 7 ... whoa, whoa, who said anything about Windows 8?
Start migrating now to avoid another XPocalypse – Gartner
You'll find Yoda at the back of every IT conference
The piss always taking is he. Bastard the.
prev story

Whitepapers

5 things you didn’t know about cloud backup
IT departments are embracing cloud backup, but there’s a lot you need to know before choosing a service provider. Learn all the critical things you need to know.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Build a business case: developing custom apps
Learn how to maximize the value of custom applications by accelerating and simplifying their development.
Rethinking backup and recovery in the modern data center
Combining intelligence, operational analytics, and automation to enable efficient, data-driven IT organizations using the HP ABR approach.
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.