Book review: Spring Persistence with Hibernate
Buy it now
One Minute Bottom Line
Spring Persistence with Hibernate is overall a very worthwhile read that emphasizes good development practices, like incorporation of design patterns and convention over configuration, and describes some common pitfalls to avoid when writing applications using Spring and Hibernate.
Spring Persistence with Hibernate
Spring Persistence with Hibernate from Apress covers a lot of ground in 235 pages, delving not only into the frameworks of the title, but touching on the surface of other technologies like Lucene, Grails and Spring Roo along the way to describe how they integrate with Spring and Hibernate. The authors, Paul Tepper Fisher and Brian D. Murphy start off with an overview of the common architectural concerns of applications and how Spring and Hibernate fit into that picture. From there they they show how to get started incorporating both of these frameworks into a project and discuss the concerns and best practices involved.
The Gallery application
There's a fairly good introduction to both Spring 3 and Hibernate 3.5 at the start of the book, not an exhaustive reference by any means, but more than enough to give anyone a start using these technologies. What follows is a description of the development of a fairly rich Java webapp using JPA and Spring MVC. This includes instruction on how to model the domain effectively and discuss the various options for storing and querying data available, including a nice clear chapter dedicated to transaction management issues. Along the way the authors incorporate full text search support with Lucene and RESTful web services, leveraging Dozer for mapping domain objects to and from DTOs, into the application. I was very happy to see the “Effective Testing” chapter, which does a great job of describing some of the tools available to help test your Spring applications.
Alternative frameworks that leverage Spring and
Rounding out the last couple of chapters is an exploration of the Spring/Hibernate combination in a couple of other frameworks. First the authors port the already described application over to Grails, and discuss how GORM and the Active Record pattern contrast with the strict DAO pattern applied in the Java app. While this is indeed a short, sweet introduction to Grails, since I'm already firmly in that camp and fairly familiar with Grails, I didn't get a lot of value from this chapter. When they again port the app, this time to Spring Roo, I got a lot more interested in the productivity tools available in a pure Java environment. It was at least enough to convince me to take Roo for a test drive.
I would highly recommend this book to someone who hasn't worked with Spring or Hibernate before, or for someone that has used those frameworks and wanted to get a better idea of the 'big picture' of how they work together. However, if you're looking for more in depth knowledge of either Spring or Hibernate, you'd probably be better off with a more specific reference book.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)