public abstract class SessionFactoryUtils
extends java.lang.Object
Used internally by HibernateTransactionManager
.
Can also be used directly in application code.
HibernateExceptionTranslator
,
HibernateTransactionManager
Modifier and Type | Field and Description |
---|---|
static int |
SESSION_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up Hibernate Sessions.
|
Constructor and Description |
---|
SessionFactoryUtils() |
Modifier and Type | Method and Description |
---|---|
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 the
org.springframework.dao hierarchy. |
static javax.sql.DataSource |
getDataSource(SessionFactory sessionFactory)
Determine the DataSource of the given SessionFactory.
|
public static final int SESSION_SYNCHRONIZATION_ORDER
DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 100
to execute Session cleanup before JDBC Connection cleanup, if any.public static void closeSession(@Nullable Session session)
session
- the Hibernate Session to close (may be null
)SharedSessionContract.close()
@Nullable public static javax.sql.DataSource getDataSource(SessionFactory sessionFactory)
sessionFactory
- the SessionFactory to checknull
if none foundConnectionProvider
public static DataAccessException convertHibernateAccessException(HibernateException ex)
org.springframework.dao
hierarchy.ex
- HibernateException that occurredHibernateExceptionTranslator.convertHibernateAccessException(org.hibernate.HibernateException)
,
HibernateTransactionManager.convertHibernateAccessException(org.hibernate.HibernateException)