Patrick mentions in this post that the book takes readers through developing a naive Hibernate DAO and then enhances this using Spring.
Does the book go into any detail about Spring/Hibernate integration. Do the two products complement themselves here?
posted 11 years ago
We do cover Spring in Chapter 7, the title of which is "Organizing with Spring and data access objects". I'm a big fan of Spring's integration with Hibernate and think they compliment each other very well.
We cover using the HibernateTemplate, which is Spring's wrapper around the Session, handling opening and cleaning up the session, parsing database specific error messages to create an Exception hierachy (classes like DataIntegrityViolationException and OptimisticLockingFailureException).
We also cover using Spring to configure the Hibernate SessionFactory and datasources, as well as how to connect your DAO's, which can use Spring's layer supertype, HibernateDaoSupport. That class provides an easy connection to the SessionFactory with some useful convience methods like releaseSession(Session) and getSession().
Much of the discussion in chapter 7 aims to show why Spring is useful by implementing a DAO without Spring, then refactoring to show how much less code the Spring DAO actually requires.