Book Review: "Harnessing Hibernate" in Light of ColdFusion 9

It's no secret that ColdFusion 9 will have Object-Relational Mapping capabilities baked in, thanks to the inclusion of the open-source and very powerful Hibernate ORM engine. In order to get ready for this major new addition to ColdFusion, I thought it would be wise to read up on Hibernate and take a look at what it can and can't do in CF9. CF9 is still very much a moving target, and we don't know for sure exactly what features in Hibernate it will support (though more information is leaking out), but it's good to go to the source and see what kind of possibilities might be available to us.

To that end, I picked up a copy of O'Reilly's "Harnessing Hibernate." It's a book targeted at Java developers. There's no mention of using Hibernate with CF, Groovy, Python or any other language in the book. So if you have absolutely no familiarity with Java, the significant time that the book spends walking through sample Java code is going to likely confuse you (although, really, Java is pretty easy to read if you write a lot of CFCs, write in cfscript or JavaScript). The book also assumes that you have at least a passing familiarity with Ant, and, by extension, Maven. It spends lots and lots of time on Maven, as a matter of fact, which I'll discuss a bit later. This should come as no surprise, really, because if you're doing a lot of Java work, you're going to have used Ant at least a few times.

The real strength of the book is in the examples it contains which demonstrate the advantages of using an ORM like Hibernate over managing object persistence on your own. The examples are very clear, and build upon each other throughout the book. All of the basics of using Hibernate are covered, in detail, including how Hibernate sessions work and the performance implications that Hibernate sessions have. A good chunk of the book is devoted to showing how easy Hibernate can make things for your Java projects, but as a ColdFusion developer, I'm used to my Web application middleware making things easier.

This also points to one of the shortcomings of the book: it spends so much time trying to convince you that Hibernate is great (and it is) and a huge time-saver (and it is), that once the basics are covered, and you're just at the point of wanting to go just beyond the basics, the authors refer you to the Hibernate documentation available online. I would have appreciated more examples of marking up the Hibernate.hbm.xml file to solve certain relational database and object mapping problems. There isn't a whole lot of XML on display here (and that's a good thing for some people), as Annotations are encouraged soon after the XML configuration is introduced. I suppose you could make the argument that the book shouldn't dwell too heavily on the XML config as that is documented on the Hibernate Web site, and that showing you how to change your code to utilize Hibernate is much more important.

As I hinted at before, the other major shortcoming of the book, to me, was the over-emphasis on Maven and utilizing Maven to manage build dependencies in your Java projects. The book could have been called "Harnessing Hibernate and Maven" for all the time spent on Maven throughout the book. Maven's great, I'm sure, but I wanted to learn primarily about Hibernate, not Maven.

The book has an excellent chapter on using Hibernate's Eclipse tools for modeling your Hibernate configuration, as well as a couple of chapters on Hibernate, Spring, and other Web frameworks. Those won't be of as immediate use to CF developers as Java developers, but, again, they help to provide a broad introduction to how Hibernate can be integrated in a variety of Java-based projects.

Having read quite a bit now about how you integrate Hiberante in to your Java projects and all the build and dependency resolution that needs to happen, I'm glad that I'll soon enough be able to work with Hibernate in CF, letting CF mask most of that setup complexity so I can spend my time on solving more interesting problems.

Comments
Comments are not allowed for this entry.
BlogCFC was created by Raymond Camden.

Creative Commons License
The content on http://www.iterateme.com/ is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.