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.
| Modifiers | Name | Description |
|---|---|---|
static int |
SESSION_SYNCHRONIZATION_ORDER |
Order value for TransactionSynchronization objects that clean up Hibernate Sessions. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
closeSession(Session session)Perform actual closing of the Hibernate Session, catching and logging any cleanup exceptions thrown. |
|
public static DataAccessException |
convertHibernateAccessException(HibernateException ex)Convert the given HibernateException to an appropriate exception from the org.springframework.dao hierarchy. |
|
public static javax.sql.DataSource |
getDataSource(SessionFactory sessionFactory)Determine the DataSource of the given SessionFactory. |
Order value for TransactionSynchronization objects that clean up Hibernate Sessions.
Returns DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 100
to execute Session cleanup before JDBC Connection cleanup, if any.
Perform actual closing of the Hibernate Session, catching and logging any cleanup exceptions thrown.
session - the Hibernate Session to close (may be null) Convert the given HibernateException to an appropriate exception
from the org.springframework.dao hierarchy.
ex - the HibernateException that occurredDetermine the DataSource of the given SessionFactory.
sessionFactory - the SessionFactory to checknull if none found