Requires a SessionFactory to be set, providing a
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 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.

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(org.hibernate.SessionFactory).

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 DaoSupport.initDao() implementation).
Consider creating a custom HibernateTemplate instance via
new HibernateTemplate(getSessionFactory()), in which
case you're allowed to customize the settings on the resulting instance.

getSession

Obtain a Hibernate Session, either from the current transaction or
a new one. The latter is only allowed if the
"allowCreate"
setting of this bean's HibernateTemplate is "true".

Note that this is not meant to be invoked from HibernateTemplate code
but rather just in plain Hibernate code. Either rely on a thread-bound
Session or use it in combination with releaseSession(org.hibernate.Session).

In general, it is recommended to use HibernateTemplate, either with
the provided convenience operations or with a custom HibernateCallback
that provides you with a Session to work on. HibernateTemplate will care
for all resource management and for proper exception conversion.

getSession

Obtain a Hibernate Session, either from the current transaction or
a new one. The latter is only allowed if "allowCreate" is true.

Note that this is not meant to be invoked from HibernateTemplate code
but rather just in plain Hibernate code. Either rely on a thread-bound
Session or use it in combination with releaseSession(org.hibernate.Session).

In general, it is recommended to use
HibernateTemplate, either with
the provided convenience operations or with a custom
HibernateCallback that
provides you with a Session to work on. HibernateTemplate will care
for all resource management and for proper exception conversion.

Parameters:

allowCreate - if a non-transactional Session should be created when no
transactional Session can be found for the current thread