Technology: Hibernate


In the Basic example, Spring JDBC-templates are used to ease the development of the persistence layer (accessing a relational database). You may, however, also have recognized that most of the DAO code is the mapping between the Java objects (also called POJOs - Plain Old Java Objects) and the (usually relational) database. Object-relational mapping tools aim at doing exactly that for you with little effort from your side.

But it should be noted here, that O/R tools like Hibernate are actually instrinsically very complex tools. They can contribute to a clean and efficient application design, particularly when complex object-graphs in large applications have to be persisted. In simple applications the usage of O/R tools is typically an overkill. One thing has to be clear anyway: the additional complexity of O/R tools must not be underestimated and a very skilled expert should be available to configure the system appropriately. Otherwise the whole project might be in jeopardy!

In many cases "better" object to SQL mapping using mybatis might be the best way to go.

Hibernate ( and Castor ( are the two most popular ORM-tools at the moment. Hibernate is tightly integrated into Java and now also into JBoss and is used in the "Medium" example, the webapplication alongside with Java Server Faces technology.

Even tough Hibernate does most of the work, we still have to tell Hibernate how to map the objects to the table. This can be done in multiple ways. Check out the Medium example for details.

The DAOs that use Hibernate are very short and you can instantly see how Hibernate makes writing the persistence layer really easy.


Hibernate has also a great documentation that you should look at: (other languages are also available at