类 SessionFactoryUtils
- java.lang.Object
- org.springframework.orm.hibernate5.SessionFactoryUtils
public abstract class SessionFactoryUtils extends Object
Helper class featuring methods for Hibernate Session handling. Also provides support for exception translation.Used internally by
HibernateTransactionManager
. Can also be used directly in application code.- 从以下版本开始:
- 4.2
- 作者:
- Juergen Hoeller
- 另请参阅:
HibernateExceptionTranslator
,HibernateTransactionManager
字段概要
字段 修饰符和类型 字段 说明 static int
SESSION_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up Hibernate Sessions.
构造器概要
构造器 构造器 说明 SessionFactoryUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static void
closeSession(Session session)
Perform actual closing of the Hibernate Session, catching and logging any cleanup exceptions thrown.static DataAccessException
convertHibernateAccessException(HibernateException ex)
Convert the given HibernateException to an appropriate exception from theorg.springframework.dao
hierarchy.static DataSource
getDataSource(SessionFactory sessionFactory)
Determine the DataSource of the given SessionFactory.
字段详细资料
SESSION_SYNCHRONIZATION_ORDER
public static final int SESSION_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up Hibernate Sessions. ReturnsDataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 100
to execute Session cleanup before JDBC Connection cleanup, if any.
构造器详细资料
SessionFactoryUtils
public SessionFactoryUtils()
方法详细资料
closeSession
public static void closeSession(Session session)
Perform actual closing of the Hibernate Session, catching and logging any cleanup exceptions thrown.- 参数:
session
- the Hibernate Session to close (may benull
)- 另请参阅:
Session.close()
getDataSource
public static DataSource getDataSource(SessionFactory sessionFactory)
Determine the DataSource of the given SessionFactory.- 参数:
sessionFactory
- the SessionFactory to check- 返回:
- the DataSource, or
null
if none found - 另请参阅:
ConnectionProvider
convertHibernateAccessException
public static DataAccessException convertHibernateAccessException(HibernateException ex)
Convert the given HibernateException to an appropriate exception from theorg.springframework.dao
hierarchy.- 参数:
ex
- HibernateException that occurred- 返回:
- the corresponding DataAccessException instance
- 另请参阅:
HibernateExceptionTranslator.convertHibernateAccessException(org.hibernate.HibernateException)
,HibernateTransactionManager.convertHibernateAccessException(org.hibernate.HibernateException)