Hibernate is a glorified data access objects that provide a list of APIs to do database operation with objects. It works well as long as one person in the team understands the tool really well. Though the documentation is relatively better than those other open source products have, there is a sharp learning curve if you have not worked with it yet. This learning curve can make or break your project. This is not to discourage users but to warn that if you are doing this for the first time, have ample time to configure and write hibernate related codes. This is the only risk on the project. If you have an experienced Hibernate developer, then you are saving â€œTONSâ€ of development time.
The sunny side of Hibernate, if you are using tools to generate hibernate mapping and objects (in my project his is a must have requirement not a wish list), is a terrific tool that force your database design through the Object Relation mapping. Had not it been Hibernate, we would not have found many database design issues. The Hibernate OR mapping forced us to clean up our database. I must say that his is the single most value adds of such product.
Once we had our act together, the persistence layer using Hibernate is such a clean set of code that I have not seen with JDBC programming. The changes to Hibernate are much simpler, faster, and painless. This is the benefit of using such tool like Hibernate.
What to look out for?
Make sure that you use generation tool to generate mapping file, data objects, and homes (data access object).
If you have complex database relationship, make sure you fix your â€˜equalâ€™ and â€˜hashâ€™ method. Hibernate generate fairly complex methods. If it is for a table without relationship, then it is fantastic. If it for a table with a lot relationship, then you are better off cleaning up the methods just to use key from tables.
Make sure you make decision for set vs list vs collection when you have one to many or many to many relationship. This is crucial as your code base dependent on the data obects. Hibernate seem to prefer â€˜setâ€™ class; however, we wrote our code for â€˜listâ€™ class. Hibernate is as a matter a fact written for set. The downsize of using list that we have found is that it creates list with empty objects which we have not figure out what to do yet.
Make sure Session and Transactions are handled correctly. They are not forgiving.
Make sure your application server and hibernate versions are compatible. This can be tested by deploying a simple startup JSP page and querying a table from it. It works it works.
Make sure data objects generated from Hibernate tool are always generated. No change is allowed to this object. If you need custom coding in those objects, then use extension of object such as DataObjectImpl that implements the DataObject. Then you can add all your custom codes. This has worked really well for us.