Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring 3.1 + Hibernate 4 - HibernateTemplate

Spring's hibernate4 package appears to have done away with HibernateTemplate and HibernateDaoSupport. I'm in the process of upgrading Hibernate from 3 to 4 in my Spring app and I have a fair few subclasses of Spring's HibernateDaoSupport and a couple of Hibernate callbacks through HibernateTemplate. Perhaps I'm not using the right search terms, but I can't find any info in the reference docs on how I should be refactoring these to "use plain hibernate daos as explained in the reference guide". Can anyone help point me in the right direction?

like image 926
spume Avatar asked May 30 '12 14:05

spume


1 Answers

The javadoc of HibernateTemplate explains it. You should use sessionFactory.getCurrentSession() to get a session, and use the native Hibernate Session API directly.

like image 124
JB Nizet Avatar answered Oct 07 '22 02:10

JB Nizet