The framework architecture
Header

Hibernate

Hibernate is an open-source Object/Relational Mapping (ORM) solution. ORM is the technique of mapping an Object model to a Relational model (usually represented by a SQL database). Hibernate was created in late 2001 by Gavin King and a handful of other developers. Since then, Hibernate has become a very popular persistence framework in the Java Community. It’s become so popular in fact, that the next versions of EJB and JDO are using Hibernate as a source of good ideas. The reasons for its popularity are mainly due to its good documentation, ease of use, excellent features and smart project management. Hibernate’s license is LGPL, which means you can use it and distribute as long as you don’t modify its source code. More information on its license is available on the Hibernate website.

Hibernate frees you from hand-coding JDBC. Rather than using SQL and JDBC, you can use domain objects (which are usually POJOs) and use annotations to map that object to a relational database. Annotations indicate which fields (in an object) map to which columns (in a table). Hibernate has a powerful query language called Hibernate Query Language (HQL). This language allows you to write SQL, but also use object-oriented semantics. One of the best parts about its query language is you can literally guess at its syntax and get it right.

Hibernate’s Session interface is similar to a database connection in that it must be opened and closed at appropriate times to avoid errors and memory leaks. In my opinion, the biggest advantage of using Spring with Hibernate is that you don’t have to manage opening and closing these Sessions – everything just works.

Learn More

Hibernate has quickly become the de-facto standard for doing persistence in Java. This has resulted in a number of books about the project. While you shouldn’t need to buy any books, there are a couple of good ones available:

Hibernate’s Reference Documentation is also a great source of information.