java.lang.Object
org.hibernate.context.ManagedSessionContext
- All Implemented Interfaces:
- CurrentSessionContext, java.io.Serializable
- public class ManagedSessionContext
- extends java.lang.Object
- implements CurrentSessionContext
Represents a CurrentSessionContext the notion of a contextual session
is managed by some external entity (generally some form of interceptor, etc).
This external manager is responsible for scoping these contextual sessions
appropriately binding/unbinding them here for exposure to the application
through SessionFactory.getCurrentSession()>SessionFactory.getCurrentSession() 55 calls.
Basically exposes two interfaces.
The underlying storage of the current sessions here is a static
java.lang.ThreadLocal-based map where the sessions are keyed by the
the owning session factory.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
context
private static final java.lang.ThreadLocal context
factory
private final org.hibernate.engine.SessionFactoryImplementor factory
ManagedSessionContext
public ManagedSessionContext(org.hibernate.engine.SessionFactoryImplementor factory)
currentSession
public org.hibernate.classic.Session currentSession()
- Description copied from interface:
CurrentSessionContext
- Retrieve the current session according to the scoping defined
by this implementation.
- Specified by:
currentSession in interface CurrentSessionContext
hasBind
public static boolean hasBind(org.hibernate.SessionFactory factory)
- Check to see if there is already a session associated with the current
thread for the given session factory.
bind
public static org.hibernate.classic.Session bind(org.hibernate.classic.Session session)
- Binds the given session to the current context for its session factory.
unbind
public static org.hibernate.classic.Session unbind(org.hibernate.SessionFactory factory)
- Unbinds the session (if one) current associated with the context for the
given session.
existingSession
private static org.hibernate.classic.Session existingSession(org.hibernate.SessionFactory factory)
sessionMap
protected static java.util.Map sessionMap()
sessionMap
private static java.util.Map sessionMap(boolean createMap)
doCleanup
private static void doCleanup()