Methods Summary |
---|
public static org.hibernate.classic.Session | bind(org.hibernate.classic.Session session)Binds the given session to the current context for its session factory.
return ( Session ) sessionMap( true ).put( session.getSessionFactory(), session );
|
public org.hibernate.classic.Session | currentSession()
Session current = existingSession( factory );
if ( current == null ) {
throw new HibernateException( "No session currently bound to execution context" );
}
return current;
|
private static synchronized void | doCleanup()
Map sessionMap = sessionMap( false );
if ( sessionMap != null ) {
if ( sessionMap.isEmpty() ) {
context.set( null );
}
}
|
private static org.hibernate.classic.Session | existingSession(org.hibernate.SessionFactory factory)
Map sessionMap = sessionMap();
if ( sessionMap == null ) {
return null;
}
else {
return ( Session ) sessionMap.get( factory );
}
|
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.
return existingSession( factory ) != null;
|
protected static java.util.Map | sessionMap()
return sessionMap( false );
|
private static synchronized java.util.Map | sessionMap(boolean createMap)
Map sessionMap = ( Map ) context.get();
if ( sessionMap == null && createMap ) {
sessionMap = new HashMap();
context.set( sessionMap );
}
return sessionMap;
|
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.
Session existing = null;
Map sessionMap = sessionMap();
if ( sessionMap != null ) {
existing = ( Session ) sessionMap.remove( factory );
doCleanup();
}
return existing;
|