org.springframework.orm.hibernate.support
Class HibernateDaoSupport


public abstract class HibernateDaoSupport
implements InitializingBean

Convenient super class for Hibernate data access objects.

Requires a SessionFactory to be set, providing a HibernateTemplate based on it to subclasses. Can alternatively be initialized directly via a HibernateTemplate, to reuse the latter's settings like SessionFactory, flush mode, exception translator, etc.

This base class is mainly intended for HibernateTemplate usage but can also be used when working with SessionFactoryUtils directly, e.g. in combination with HibernateInterceptor-managed Sessions. Convenience getSession and closeSessionIfNecessary methods are provided for that usage.

Author:
Juergen Hoeller
Since: 28.07.2003
See Also: setSessionFactory(SessionFactory), setHibernateTemplate(org.springframework.orm.hibernate.HibernateTemplate), HibernateTemplate, HibernateInterceptor

Method Summary
 final voidafterPropertiesSet()
           
 final voidsetHibernateTemplate(HibernateTemplate hibernateTemplate)
          Set the HibernateTemplate for this DAO explicitly, as an alternative to specifying a SessionFactory.
 final voidsetSessionFactory(SessionFactory sessionFactory)
          Set the Hibernate SessionFactory to be used by this DAO.

Method Detail

afterPropertiesSet

public final void afterPropertiesSet()
throws java.lang.Exception

setHibernateTemplate

public final void setHibernateTemplate(HibernateTemplate hibernateTemplate)
Set the HibernateTemplate for this DAO explicitly, as an alternative to specifying a SessionFactory.

setSessionFactory

public final void setSessionFactory(SessionFactory sessionFactory)
Set the Hibernate SessionFactory to be used by this DAO.

Association Links

to Class org.springframework.orm.hibernate.HibernateTemplate