Feeds

Beginning Hibernate

More object relational mapping

Internet Security Threat Report 2014

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

Beginner's guide to SSL certificates

More from The Register

next story
PEAK APPLE: iOS 8 is least popular Cupertino mobile OS in all of HUMAN HISTORY
'Nerd release' finally staggers past 50 per cent adoption
Microsoft to bake Skype into IE, without plugins
Redmond thinks the Object Real-Time Communications API for WebRTC is ready to roll
Microsoft promises Windows 10 will mean two-factor auth for all
Sneak peek at security features Redmond's baking into new OS
Mozilla: Spidermonkey ATE Apple's JavaScriptCore, THRASHED Google V8
Moz man claims the win on rivals' own benchmarks
FTDI yanks chip-bricking driver from Windows Update, vows to fight on
Next driver to battle fake chips with 'non-invasive' methods
DEATH by PowerPoint: Microsoft warns of 0-day attack hidden in slides
Might put out patch in update, might chuck it out sooner
Ubuntu 14.10 tries pulling a Steve Ballmer on cloudy offerings
Oi, Windows, centOS and openSUSE – behave, we're all friends here
Was ist das? Eine neue Suse Linux Enterprise? Ausgezeichnet!
Version 12 first major-number Suse release since 2009
prev story

Whitepapers

Why cloud backup?
Combining the latest advancements in disk-based backup with secure, integrated, cloud technologies offer organizations fast and assured recovery of their critical enterprise data.
Forging a new future with identity relationship management
Learn about ForgeRock's next generation IRM platform and how it is designed to empower CEOS's and enterprises to engage with consumers.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
New hybrid storage solutions
Tackling data challenges through emerging hybrid storage solutions that enable optimum database performance whilst managing costs and increasingly large data stores.
Getting ahead of the compliance curve
Learn about new services that make it easy to discover and manage certificates across the enterprise and how to get ahead of the compliance curve.