magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

“Hibernate”:http://www.hibernate.org/, as you may or may not be aware is a persistence engine for Java. As such it is by no means unique – it joins the ranks of JDO, Java Serialisation and the persistence features of the EJB specification as another option in an already crowded market. Good overviews on Hibernate can be found at the “official site(Hibernate and Tomcat Quickstart)”:http://www.hibernate.org/hib_docs/examples/quickstart/html/quickstart.html and in an article over at “The ServerSide(The ServerSide – Introduction To Hibernate)”:http://www.theserverside.com/resources/article.jsp?l=Hibernate

I like several things about Hibernate. Firstly it seems a lot quicker to develop than EJBs are.The classes you want to persist don’t need stub classes, or special interfaces – they are just normal beans. So not only can you quickly create these classes using code generation tools already in most modern Ode’s, but the beans themselves are abstracted from the method of persistence being used. Hibernate even ships with a tool to generate these classes from your mapping files, which is handy when used as part of an Ant build. Next, the definition of relationships is fairly easy – as is implementing lazy loading. The fact that you have to keep a Hibernate session if you want to use lazy loading of relationships is a pain but understandable.

The mapping files (which define the relationships between beans to be persisted and the datasource) is very straightforward, and as another nice touch Hibernate can read your mapping files and automatically create and keep in sync the database tables – again a great feature as part of a development build and deployment.

The reduced development overhead compared to EJB development coupled with the apparent performance improvements over simple untuned EJB applications means that I may find myself using this more and more. This weekend I’ll try and get a Hibernate-JBoss install working to carry out some simple performance comparisons between an EJB-based persistence and Hibernate based persistence.

Advertisements

2 Responses to “A Brief Overview Of Hibernate”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

%d bloggers like this: