java.lang.Object
org.hibernate.context.JTASessionContext
- All Implemented Interfaces:
- CurrentSessionContext, java.io.Serializable
- public class JTASessionContext
- extends java.lang.Object
- implements CurrentSessionContext
An implementation of CurrentSessionContext which scopes the notion
of a current session to a JTA transaction. Because JTA gives us a nice
tie-in to clean up after ourselves, this implementation will generate
Sessions as needed provided a JTA transaction is in effect. If a session
is not already associated with the current JTA transaction at the time
currentSession() 55 is called, a new session will be opened and it
will be associated with that JTA transaction.
Note that the sessions returned from this method are automatically configured with
both the
auto-flush 55 and
auto-close 55 attributes set to
true, meaning that the Session will be automatically flushed and closed
as part of the lifecycle for the JTA transaction to which it is associated.
Additionally, it will also be configured to aggressively release JDBC
connections after each statement is executed. These settings are governed
by the
isAutoFlushEnabled() 55 ,
isAutoCloseEnabled() 55 , and
getConnectionReleaseMode() 55 methods; these are provided (along with
the
buildOrObtainSession() 55 method) for easier subclassing for custom
JTA-based session tracking logic (like maybe long-session semantics).
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private static final org.apache.commons.logging.Log log
factory
protected final org.hibernate.engine.SessionFactoryImplementor factory
currentSessionMap
private transient java.util.Map currentSessionMap
JTASessionContext
public JTASessionContext(org.hibernate.engine.SessionFactoryImplementor factory)
currentSession
public org.hibernate.classic.Session currentSession()
throws org.hibernate.HibernateException
- Description copied from interface:
CurrentSessionContext
- Retrieve the current session according to the scoping defined
by this implementation.
- Specified by:
currentSession in interface CurrentSessionContext
buildCleanupSynch
private JTASessionContext.CleanupSynch buildCleanupSynch(javax.transaction.Transaction txn)
buildOrObtainSession
protected org.hibernate.classic.Session buildOrObtainSession()
- Strictly provided for subclassing purposes; specifically to allow long-session
support.
This implementation always just opens a new session.
isAutoCloseEnabled
protected boolean isAutoCloseEnabled()
- Mainly for subclass usage. This impl always returns true.
isAutoFlushEnabled
protected boolean isAutoFlushEnabled()
- Mainly for subclass usage. This impl always returns true.
getConnectionReleaseMode
protected org.hibernate.ConnectionReleaseMode getConnectionReleaseMode()
- Mainly for subclass usage. This impl always returns after_statement.