HibernateDAOSupport vs HibernateTemplate

1.4k views Asked by At

I am trying to understand the benefit which HibernateDAOSupport provides over HibernateTemplate. HibernateTemplate pretty much does everything. Then why do we need to extend HibernateDAOSupport and getHibernateTemplate and do the operations rather than injecting the hibernateTemplate and do the operations. What is the benefit we get when the DAO classes extend HibernateDAOSupport.

I know that it is not recommended to use HibernateDAOSupport and HibernateTemplate anymore but just trying to understand the difference.

1

There are 1 answers

0
Jens Schauder On

This is a little guess work after skimming through the API:

It looks like at first there was the HibernateTemplate which hid the session completely and if you needed access to the Session DaoSupport would offer you that.

From HibernateDaoSupport JavaDoc:

This base class is mainly intended for HibernateTemplate usage but can also be used when working with a Hibernate Session directly, for example when relying on transactional Sessions. Convenience getSession() and releaseSession(org.hibernate.Session) methods are provided for that usage style.

But the getSession method in DaoSupport is now deprecated for HibernateSession, which has basically the same method now. So the only thing left in DaoSupport, which you don't get in the Template seems to be releaseSession which is also deprecated, but I can't find it in HibernateTemplate API.

tl;dr;

These are just left overs from an age long ago. Don't worry to much if you aren't an archaeologist.