org.jboss.hibernate.session
Class HibernateContext

java.lang.Object
  extended byorg.jboss.hibernate.session.HibernateContext

Deprecated. Direct use of the new org.hibernate.SessionFactory#getCurrentSession() method is the preferred approach to managing "transaction contextual sessions".

public class HibernateContext
extends java.lang.Object

Maintains and exposes, for app usage, the current context bound Hibernate Session. Application code need only deal with the getSession(java.lang.String) as the means to retreive the org.hibernate.Session associated with the current context.


Constructor Summary
HibernateContext()
          Deprecated.  
 
Method Summary
static Session getSession(java.lang.String name)
          Deprecated. Given a SessionFactory, sf (usually obtained from JNDI), this method is equivalent to
sf.getCurrentSession()
.
static Session getUnmanagedSession(java.lang.String name)
          Deprecated. Given a SessionFactory, sf (usually obtained from JNDI), this method is equivalent to
sf.openSession( sf.getCurrentSession().connection() )
static void releaseUnmanagedSession(Session unmanagedSession)
          Deprecated. See getUnmanagedSession(String)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateContext

public HibernateContext()
Deprecated. 
Method Detail

getUnmanagedSession

public static Session getUnmanagedSession(java.lang.String name)
                                   throws HibernateException,
                                          java.lang.IllegalStateException
Deprecated. Given a SessionFactory, sf (usually obtained from JNDI), this method is equivalent to
sf.openSession( sf.getCurrentSession().connection() )

Retreives an "unmanaged" session against the same underlying jdbc connnection as the session currently bound to the current context for the given JNDI name. This is simply a convenience method for SessionFactory.openSession(getSession(java.lang.String).connection()). Unmanaged here means that the returned session is not controlled by the code managing the actually bound session; callers are required to cleanup these sessions manually using releaseUnmanagedSession(Session).

Parameters:
name - The "name" of the org.hibernate.SessionFactory for which an unmanaged session is requested.
Returns:
An unmanaged session.
Throws:
HibernateException - If an error occurs opening the new Session.
java.lang.IllegalStateException - If unable to locate a managed Session for the current context.

releaseUnmanagedSession

public static void releaseUnmanagedSession(Session unmanagedSession)
                                    throws HibernateException
Deprecated. See getUnmanagedSession(String)

Method to release a previously obtained unmanaged session.

Parameters:
unmanagedSession - The unmanaged Session to release.
Throws:
HibernateException - If an error occurs releasing the unmanaged Session.

getSession

public static Session getSession(java.lang.String name)
Deprecated. Given a SessionFactory, sf (usually obtained from JNDI), this method is equivalent to
sf.getCurrentSession()
.

Retreives the session currently bound to the current context.

Parameters:
name - The "name" of the org.hibernate.SessionFactory for which a session is requested.
Returns:
The current session.
See Also:
org.hibernate.SessionFactory#getCurrentSession()