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 |
|---|---|
(package private) static Log |
logger |
private static java.lang.reflect.Method |
openSessionMethod
A Method handle for the
SessionFactory.openSession() method. |
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.
|
static Session |
openSession(SessionFactory sessionFactory)
Obtain a new Session from 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.private static final java.lang.reflect.Method openSessionMethod
SessionFactory.openSession() method.
The return value differs between Hibernate 3.x and 4.x; for cross-compilation purposes,
we have to use reflection here as long as we keep compiling against Hibernate 3.x jars.static final Log logger
public static javax.sql.DataSource getDataSource(SessionFactory sessionFactory)
sessionFactory - the SessionFactory to checknull if none foundorg.hibernate.engine.spi.SessionFactoryImplementor#getConnectionProviderpublic static Session openSession(SessionFactory sessionFactory)
Bridges between Hibernate signature differences.
sessionFactory - the SessionFactory to useorg.hibernate.SessionFactory#openSession()public static void closeSession(Session session)
session - the Hibernate Session to close (may be null)org.hibernate.Session#close()public static DataAccessException convertHibernateAccessException(HibernateException ex)
org.springframework.dao hierarchy.ex - HibernateException that occuredHibernateExceptionTranslator.convertHibernateAccessException(HibernateException),
HibernateTransactionManager.convertHibernateAccessException(HibernateException)