abstract class HibernateDaoSupport : DaoSupport
Convenient super class for Hibernate-based data access objects.
Requires a SessionFactory to be set, providing a org.springframework.orm.hibernate5.HibernateTemplate based on it to subclasses through the #getHibernateTemplate() method. Can alternatively be initialized directly with a HibernateTemplate, in order to reuse the latter's settings such as the SessionFactory, exception translator, flush mode, etc.
This class will create its own HibernateTemplate instance if a SessionFactory is passed in. The "allowCreate" flag on that HibernateTemplate will be "true" by default. A custom HibernateTemplate instance can be used through overriding #createHibernateTemplate.
NOTE: Hibernate access code can also be coded in plain Hibernate style. Hence, for newly started projects, consider adopting the standard Hibernate style of coding data access objects instead, based on SessionFactory#getCurrentSession(). This HibernateTemplate primarily exists as a migration helper for Hibernate 3 based data access code, to benefit from bug fixes in Hibernate 5.x.
Author
Juergen Hoeller
Since
4.2
See Also
#setSessionFactory#getHibernateTemplateorg.springframework.orm.hibernate5.HibernateTemplate
HibernateDaoSupport()
Convenient super class for Hibernate-based data access objects. Requires a SessionFactory to be set, providing a org.springframework.orm.hibernate5.HibernateTemplate based on it to subclasses through the This class will create its own HibernateTemplate instance if a SessionFactory is passed in. The "allowCreate" flag on that HibernateTemplate will be "true" by default. A custom HibernateTemplate instance can be used through overriding NOTE: Hibernate access code can also be coded in plain Hibernate style. Hence, for newly started projects, consider adopting the standard Hibernate style of coding data access objects instead, based on |
fun getHibernateTemplate(): HibernateTemplate
Return the HibernateTemplate for this DAO, pre-initialized with the SessionFactory or set explicitly. Note: The returned HibernateTemplate is a shared instance. You may introspect its configuration, but not modify the configuration (other than from within an |
|
fun getSessionFactory(): SessionFactory
Return the Hibernate SessionFactory used by this DAO. |
|
fun setHibernateTemplate(hibernateTemplate: HibernateTemplate): Unit
Set the HibernateTemplate for this DAO explicitly, as an alternative to specifying a SessionFactory. |
|
fun setSessionFactory(sessionFactory: SessionFactory): Unit
Set the Hibernate SessionFactory to be used by this DAO. Will automatically create a HibernateTemplate for the given SessionFactory. |