|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.interface21.orm.hibernate.SessionFactoryUtils
Helper class featuring methods for Hibernate session handling, allowing for reuse of Hibernate Session instances within transactions. Supports synchronization with JTA transactions via JtaTransactionManager, to allow for proper transactional handling of the JVM-level cache. Used by HibernateTemplate, HibernateInterceptor, and HibernateTransactionManager.
Note: This class, like all of Spring's Hibernate support, requires Hibernate 2.0 (initially developed with RC1).
HibernateTemplate,
HibernateInterceptor,
HibernateTransactionManager,
JtaTransactionManager| Constructor Summary | |
SessionFactoryUtils()
|
|
| Method Summary | |
static void |
closeSessionIfNecessary(net.sf.hibernate.Session session,
net.sf.hibernate.SessionFactory sessionFactory)
Close the given Session, created via the given factory, if it isn't bound to the thread. |
static DataAccessException |
convertHibernateAccessException(net.sf.hibernate.HibernateException ex)
Convert the given HibernateException to an appropriate exception from the com.interface21.dao hierarchy. |
static net.sf.hibernate.SessionFactory |
createSessionFactory(java.lang.String configLocation)
Create a Hibernate SessionFactory with the given config file. |
static net.sf.hibernate.Session |
getSession(net.sf.hibernate.SessionFactory sessionFactory,
boolean allowCreate)
Get a Hibernate Session for the given factory. |
static ThreadObjectManager |
getThreadObjectManager()
Return the thread object manager for Hibernate sessions, keeping a SessionFactory/SessionHolder map per thread for Hibernate transactions. |
static boolean |
isSessionBoundToThread(net.sf.hibernate.Session session,
net.sf.hibernate.SessionFactory sessionFactory)
Return if the given Session is bound to the current thread, for the given SessionFactory. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SessionFactoryUtils()
| Method Detail |
public static ThreadObjectManager getThreadObjectManager()
getSession(net.sf.hibernate.SessionFactory, boolean),
HibernateTransactionManager
public static boolean isSessionBoundToThread(net.sf.hibernate.Session session,
net.sf.hibernate.SessionFactory sessionFactory)
session - Session that should be checkedsessionFactory - SessionFactory that the Session was created with
public static net.sf.hibernate.SessionFactory createSessionFactory(java.lang.String configLocation)
throws DataAccessResourceFailureException
configLocation - location of the config file (can be a URL
or a classpath resource), or null if defaultDataAccessResourceFailureException - if the SessionFactory could not be created
public static net.sf.hibernate.Session getSession(net.sf.hibernate.SessionFactory sessionFactory,
boolean allowCreate)
throws DataAccessResourceFailureException,
java.lang.IllegalStateException
sessionFactory - Hibernate SessionFactory to create the session withallowCreate - if a new Session should be created if no thread-bound foundDataAccessResourceFailureException - if the Session couldn't be createdjava.lang.IllegalStateException - if no thread-bound Session found and allowCreate falsepublic static DataAccessException convertHibernateAccessException(net.sf.hibernate.HibernateException ex)
ex - HibernateException that occured
public static void closeSessionIfNecessary(net.sf.hibernate.Session session,
net.sf.hibernate.SessionFactory sessionFactory)
throws CleanupFailureDataAccessException
session - Session to closesessionFactory - Hibernate SessionFactory that the Session was created withDataAccessResourceFailureException - if the Session couldn't be closed
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||