|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.hibernate.session.HibernateContext
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 Session
associated with
the current context.
Constructor Summary | |
HibernateContext()
|
Method Summary | |
static void |
bind(String name,
net.sf.hibernate.Session currentSession)
Binds a session to the current context. |
static net.sf.hibernate.Session |
getSession(String name)
Retreives the session currently bound to the current context. |
static net.sf.hibernate.Session |
getUnmanagedSession(String name)
Retreives an "unmanaged" session against the same underlying jdbc connnection as the session currently bound to the current context for the given JNDI name. |
static boolean |
hasBind(String name)
Determines whether a session is already bound to the current context for the given name. |
static void |
prepareSession(String name,
net.sf.hibernate.Session session)
Prepare a session for binding. |
static void |
releaseUnmanagedSession(net.sf.hibernate.Session unmanagedSession)
Method to release a previously obtained unmanaged session. |
static net.sf.hibernate.Session |
unbind(String name)
Unbinds a session from the current context. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HibernateContext()
Method Detail |
public static net.sf.hibernate.Session getUnmanagedSession(String name) throws net.sf.hibernate.HibernateException, IllegalStateException
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(net.sf.hibernate.Session)
.
name
- The "name" of the SessionFactory
for which an unmanaged session is requested.
net.sf.hibernate.HibernateException
- If an error occurs opening the new Session.
IllegalStateException
- If unable to locate a managed Session for the current context.public static void releaseUnmanagedSession(net.sf.hibernate.Session unmanagedSession) throws net.sf.hibernate.HibernateException
unmanagedSession
- The unmanaged Session to release.
net.sf.hibernate.HibernateException
- If an error occurs releasing the unmanaged Session.public static net.sf.hibernate.Session getSession(String name)
name
- The "name" of the SessionFactory
for which a session is requested.
public static boolean hasBind(String name)
name
- The name to be checked within the current context.
public static void bind(String name, net.sf.hibernate.Session currentSession) throws net.sf.hibernate.HibernateException
unbind(java.lang.String)
(and optionally prepareSession(java.lang.String, net.sf.hibernate.Session)
) for applications to manage lifecycle of
Hibernate Sessions themselves.
Note that these methods still require that a JTA transaction be ongoing prior to
any attempt to bind the session.
name
- The name under which to bind the session.currentSession
- The session to bind
net.sf.hibernate.HibernateException
- If a session already bound under the given name
within the current context.public static net.sf.hibernate.Session unbind(String name)
name
- The name from which to unbind.
for more details.
public static void prepareSession(String name, net.sf.hibernate.Session session) throws net.sf.hibernate.HibernateException
session
- The session to prepare.name
- The name under which the session is to be bound
net.sf.hibernate.HibernateException
- If there was a problem registering the synch.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |