Realsolve Logo
Articles
 

Hibernate Tips and Pitfalls

Pointers for Successful Hibernating

By Phil Zoio, last update on 17 January 2005

Hibernate is an Object Relational Mapping (ORM) tool which has taken the Java world by storm in the last couple of years. One of the biggest headaches of enterprise software development has been the need to maintain a large amount of code to convert between objects and persistent data, which is typically stored on a relational database and accessed via SQL.

In the last few years some attempts have been made to bridge this gap. The most notable of these is the container managed persistence (CMP) part of the EJB specification. But CMP EJB in its current form (version 2.1) has failed to deliver. It is unwieldy, and simply is not sophisticated enough to bring about the performance required for many applications. The other specification, Java Data Objects (JDO) has shown promise but has suffered from lack of support from major vendors and through its perceived position as a "competitor" to EJB persistence. The other problem with JDO has been an API�perceived to be�too closely linked to object persistence solutions�rather than traditional and more established relational persistence through industry leading�RDBMS producs�such as Oracle and SQL Server.

Hibernate has rushed in to fill in the gap, bringing to the Java community an open source tool which is competitive, both in features and performance, any other tool of its kind in the marketplace. With Hibernate, the promise of being able to bridge the object-relational paradigm mismatch in an elegant way through ORM, is finally becoming a reality. Hibernate has been so successful that it is forming the basis of the forthcoming and dramatically revised EJB 3.0 specification.

Experienced users of Hibernate generally agree that it is a product which greatly enhances productivity. The difficulty with Hibernate is a relatively steep learning curve. Before becoming productive with the tool, novice developers need to learn more than simply the basic Hibernate concepts and techniques. They need to gain a relatively in depth conceptual understanding of how ORM works. And they need to know the gotchas - the pitfalls which will prevent them from working productively with the tool, and prevent their applications from performing acceptably.

This series is all about the Hibernate tips and gotchas, the things to look out for when developing Hibernate applications. Its not aimed at the absolute beginner, but at the developer who is looking to move a step beyond the basics towards becoming a successful user of Hibernate.

So far, in this series, we've covered the following:

This is a working document. If there are any errors, or if you disagree with anything which I have said, or have any suggestions for improvements please email me at philzoio@realsolve.co.uk.