Feeds

Beginning Hibernate

More object relational mapping

New hybrid storage solutions

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

Security for virtualized datacentres

More from The Register

next story
Not appy with your Chromebook? Well now it can run Android apps
Google offers beta of tricky OS-inside-OS tech
Greater dev access to iOS 8 will put us AT RISK from HACKERS
Knocking holes in Apple's walled garden could backfire, says securo-chap
NHS grows a NoSQL backbone and rips out its Oracle Spine
Open source? In the government? Ha ha! What, wait ...?
Google extends app refund window to two hours
You now have 120 minutes to finish that game instead of 15
Intel: Hey, enterprises, drop everything and DO HADOOP
Big Data analytics projected to run on more servers than any other app
New 'Cosmos' browser surfs the net by TXT alone
No data plan? No WiFi? No worries ... except sluggish download speed
prev story

Whitepapers

Providing a secure and efficient Helpdesk
A single remote control platform for user support is be key to providing an efficient helpdesk. Retain full control over the way in which screen and keystroke data is transmitted.
Top 5 reasons to deploy VMware with Tegile
Data demand and the rise of virtualization is challenging IT teams to deliver storage performance, scalability and capacity that can keep up, while maximizing efficiency.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.
Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.