I am upgrading my project from spring 3.0.5 & hibernate 3 to spring 3.1.1 & hibernate 4.1
I use org.springframework.orm.hibernate3.support.HibernateDaoSupport extensively. In concrete HibernateTemplate; like in this snippet:
public class MenuDaoImpl extends HibernateDaoSupport implements MenuDao, Serializable {
public List<Menu> getMenus() {
return getHibernateTemplate().find("from Menu menu");
}
//etc
}
But I read that HibernateTemplate isn’t recommended for use anymore.
So, what’s the recommended way to hit the database within the DAO’s in Spring3.1.1?
Thanks
Inject an EntityManager and use it directly.
Here’s a good example on the SpringSource blog.