org.springframework.orm.hibernate3
Class SessionHolder

java.lang.Object
  extended by org.springframework.transaction.support.ResourceHolderSupport
      extended by org.springframework.orm.hibernate3.SessionHolder
All Implemented Interfaces:
ResourceHolder

public class SessionHolder
extends ResourceHolderSupport

Session holder, wrapping a Hibernate Session and a Hibernate Transaction. HibernateTransactionManager binds instances of this class to the thread, for a given SessionFactory.

Note: This is an SPI class, not intended to be used by applications.

Since:
1.2
Author:
Juergen Hoeller
See Also:
HibernateTransactionManager, SessionFactoryUtils

Field Summary
private static java.lang.Object DEFAULT_KEY
           
private  FlushMode previousFlushMode
           
private  java.util.Map<java.lang.Object,Session> sessionMap
          This Map needs to be synchronized because there might be multi-threaded access in the case of JTA with remote transaction propagation.
private  Transaction transaction
           
 
Constructor Summary
SessionHolder(java.lang.Object key, Session session)
           
SessionHolder(Session session)
           
 
Method Summary
 void addSession(java.lang.Object key, Session session)
           
 void addSession(Session session)
           
 void clear()
          Clear the transactional state of this resource holder.
 boolean containsSession(Session session)
           
 boolean doesNotHoldNonDefaultSession()
           
 Session getAnySession()
           
 FlushMode getPreviousFlushMode()
           
 Session getSession()
           
 Session getSession(java.lang.Object key)
           
 Transaction getTransaction()
           
 Session getValidatedSession()
           
 Session getValidatedSession(java.lang.Object key)
           
 boolean isEmpty()
           
 Session removeSession(java.lang.Object key)
           
 void setPreviousFlushMode(FlushMode previousFlushMode)
           
 void setTransaction(Transaction transaction)
           
 
Methods inherited from class org.springframework.transaction.support.ResourceHolderSupport
getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_KEY

private static final java.lang.Object DEFAULT_KEY

sessionMap

private final java.util.Map<java.lang.Object,Session> sessionMap
This Map needs to be synchronized because there might be multi-threaded access in the case of JTA with remote transaction propagation.


transaction

private Transaction transaction

previousFlushMode

private FlushMode previousFlushMode
Constructor Detail

SessionHolder

public SessionHolder(Session session)

SessionHolder

public SessionHolder(java.lang.Object key,
                     Session session)
Method Detail

getSession

public Session getSession()

getSession

public Session getSession(java.lang.Object key)

getValidatedSession

public Session getValidatedSession()

getValidatedSession

public Session getValidatedSession(java.lang.Object key)

getAnySession

public Session getAnySession()

addSession

public void addSession(Session session)

addSession

public void addSession(java.lang.Object key,
                       Session session)

removeSession

public Session removeSession(java.lang.Object key)

containsSession

public boolean containsSession(Session session)

isEmpty

public boolean isEmpty()

doesNotHoldNonDefaultSession

public boolean doesNotHoldNonDefaultSession()

setTransaction

public void setTransaction(Transaction transaction)

getTransaction

public Transaction getTransaction()

setPreviousFlushMode

public void setPreviousFlushMode(FlushMode previousFlushMode)

getPreviousFlushMode

public FlushMode getPreviousFlushMode()

clear

public void clear()
Description copied from class: ResourceHolderSupport
Clear the transactional state of this resource holder.

Overrides:
clear in class ResourceHolderSupport