Class SessionFactoryUtils
java.lang.Object
org.springframework.orm.hibernate5.SessionFactoryUtils
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.
- Since:
- 4.2
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intOrder value for TransactionSynchronization objects that clean up Hibernate Sessions.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcloseSession(Session session) Perform actual closing of the Hibernate Session, catching and logging any cleanup exceptions thrown.static DataAccessExceptionConvert the given HibernateException to an appropriate exception from theorg.springframework.daohierarchy.static DataSourcegetDataSource(SessionFactory sessionFactory) Determine the DataSource of the given SessionFactory.
- 
Field Details- 
SESSION_SYNCHRONIZATION_ORDERpublic static final int SESSION_SYNCHRONIZATION_ORDEROrder value for TransactionSynchronization objects that clean up Hibernate Sessions. ReturnsDataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 100to execute Session cleanup before JDBC Connection cleanup, if any.
 
- 
- 
Constructor Details- 
SessionFactoryUtilspublic SessionFactoryUtils()
 
- 
- 
Method Details- 
closeSessionPerform actual closing of the Hibernate Session, catching and logging any cleanup exceptions thrown.- Parameters:
- session- the Hibernate Session to close (may be- null)
- See Also:
 
- 
getDataSourceDetermine the DataSource of the given SessionFactory.- Parameters:
- sessionFactory- the SessionFactory to check
- Returns:
- the DataSource, or nullif none found
- See Also:
 
- 
convertHibernateAccessExceptionConvert the given HibernateException to an appropriate exception from theorg.springframework.daohierarchy.- Parameters:
- ex- the HibernateException that occurred
- Returns:
- the corresponding DataAccessException instance
- See Also:
 
 
-