• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Authors: Hibernate and Spring

 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Patrick Peak
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic