Requires a SessionFactory to be set, providing a
org. 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.
setSessionFactory, getHibernateTemplate, org.springframework.orm.hibernate5.HibernateTemplate
| Modifier and Type | Field and Description |
|---|---|
| private HibernateTemplate |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected final void | checkDaoConfig()
Implements abstract org. |
| protected HibernateTemplate | Returns: the new HibernateTemplate instancethe Hibernate SessionFactory to create a HibernateTemplate for sessionFactory)
Deprecated
as a consequence of
Create a HibernateTemplate for the given SessionFactory.
SessionFactory being deprecated.
|
| protected final Session | Returns: the Hibernate Session
Deprecated
as a consequence of
Conveniently obtain the current Hibernate Session.
Session being deprecated.
|
| public final HibernateTemplate | getHibernateTemplate()
Return the HibernateTemplate for this DAO, pre-initialized with the SessionFactory or set explicitly. |
| public final SessionFactory | getSessionFactory()
Deprecated
as a consequence of
Return the Hibernate SessionFactory used by this DAO.
SessionFactory being deprecated.
|
| public final void | setHibernateTemplate(HibernateTemplate hibernateTemplate)
Set the HibernateTemplate for this DAO explicitly, as an alternative to specifying a SessionFactory. |
| public final void | setSessionFactory(SessionFactory sessionFactory)
Deprecated
as a consequence of
Set the Hibernate SessionFactory to be used by this DAO.
SessionFactory being deprecated.
|
| hibernateTemplate | back to summary |
|---|---|
| private HibernateTemplate hibernateTemplate
| |
| HibernateDaoSupport | back to summary |
|---|---|
| public HibernateDaoSupport() | |
| checkDaoConfig | back to summary |
|---|---|
| protected final void checkDaoConfig() Implements abstract org. Doc from org. Abstract subclasses must override this to check their configuration. Implementors should be marked as
| |
| createHibernateTemplate | back to summary |
|---|---|
| protected HibernateTemplate createHibernateTemplate(SessionFactory sessionFactory)
Deprecated as a consequence of Create a HibernateTemplate for the given SessionFactory. Only invoked if populating the DAO with a SessionFactory reference! Can be overridden in subclasses to provide a HibernateTemplate instance with different configuration, or a custom HibernateTemplate subclass.
| |
| currentSession | back to summary |
|---|---|
| protected final Session currentSession() throws DataAccessResourceFailureException
Deprecated as a consequence of Conveniently obtain the current Hibernate Session.
| |
| getHibernateTemplate | back to summary |
|---|---|
| public final HibernateTemplate getHibernateTemplate() 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
| |
| getSessionFactory | back to summary |
|---|---|
| public final SessionFactory getSessionFactory()
Deprecated as a consequence of Return the Hibernate SessionFactory used by this DAO.
| |
| setHibernateTemplate | back to summary |
|---|---|
| public final void setHibernateTemplate(HibernateTemplate hibernateTemplate) Set the HibernateTemplate for this DAO explicitly, as an alternative to specifying a SessionFactory.
| |
| setSessionFactory | back to summary |
|---|---|
| public final void setSessionFactory(SessionFactory sessionFactory)
Deprecated as a consequence of Set the Hibernate SessionFactory to be used by this DAO. Will automatically create a HibernateTemplate for the given SessionFactory.
| |