public abstract class AbstractHibernateDao<T> extends BaseDao<T>
HibernateDaoSupport
entityClass
构造器和说明 |
---|
AbstractHibernateDao() |
限定符和类型 | 方法和说明 |
---|---|
protected void |
closeSessionIfNecessary(org.hibernate.Session session)
Close the given Hibernate Session, created via this DAO's SessionFactory,
if it isn't bound to the thread.
|
protected org.hibernate.Session |
getSession()
Get a Hibernate Session, either from the current transaction or a new one.
|
protected org.hibernate.Session |
getSession(boolean allowCreate)
Get a Hibernate Session, either from the current transaction or
a new one.
|
protected void |
releaseSession(org.hibernate.Session session)
Close the given Hibernate Session, created via this DAO's SessionFactory,
if it isn't bound to the thread.
|
bulkUpdate, bulkUpdate, checkDaoConfig, convertHibernateAccessException, count, count, count, createHibernateTemplate, delete, delete, executeCriteria, executeCriteria, executeUniqueCriteria, find, find, find, find, find, find, findBy, findByLike, findNativeSQL, findSimpleObjects, findSimpleObjects, findUnique, findUnique, findUniqueBy, findVarargs, findWithCount, findWithCount, get, getAll, getBatchSize, getCountByCriteria, getEntityClass, getHibernateTemplate, getSessionFactory, getSimpleObject, save, savePatchAll, setHibernateTemplate, setParameters, setSessionFactory, sortCriteria, update, updatePatchAll
protected final org.hibernate.Session getSession() throws org.springframework.dao.DataAccessResourceFailureException, java.lang.IllegalStateException
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 (via HibernateInterceptor), or use it in combination with
releaseSession
.
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.
org.springframework.dao.DataAccessResourceFailureException
- if the Session couldn't be createdjava.lang.IllegalStateException
- if no thread-bound Session found and allowCreate falsereleaseSession(org.hibernate.Session)
,
SessionFactoryUtils.getSession(SessionFactory, boolean)
,
HibernateInterceptor
,
HibernateTemplate
,
HibernateCallback
protected final org.hibernate.Session getSession(boolean allowCreate) throws org.springframework.dao.DataAccessResourceFailureException, java.lang.IllegalStateException
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 (via HibernateInterceptor), or use it in combination with
releaseSession
.
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.
allowCreate
- if a non-transactional Session should be created when no
transactional Session can be found for the current threadorg.springframework.dao.DataAccessResourceFailureException
- if the Session couldn't be createdjava.lang.IllegalStateException
- if no thread-bound Session found and allowCreate falsereleaseSession(org.hibernate.Session)
,
SessionFactoryUtils.getSession(SessionFactory, boolean)
,
HibernateInterceptor
,
HibernateTemplate
,
HibernateCallback
protected final void closeSessionIfNecessary(org.hibernate.Session session)
protected final void releaseSession(org.hibernate.Session session)
Typically used in plain Hibernate code, in combination with
getSession
and convertHibernateAccessException
.
session
- Session to closeSessionFactoryUtils.releaseSession(org.hibernate.Session, org.hibernate.SessionFactory)