Spring Framework

org.springframework.orm.hibernate4
Class SpringSessionContext

java.lang.Object
  extended by org.springframework.orm.hibernate4.SpringSessionContext
All Implemented Interfaces:
java.io.Serializable, org.hibernate.context.spi.CurrentSessionContext

public class SpringSessionContext
extends java.lang.Object
implements org.hibernate.context.spi.CurrentSessionContext

Implementation of Hibernate 3.1's CurrentSessionContext interface that delegates to Spring's SessionFactoryUtils for providing a Spring-managed current Session.

This CurrentSessionContext implementation can also be specified in custom SessionFactory setup through the "hibernate.current_session_context_class" property, with the fully qualified name of this class as value.

Since:
3.1
Author:
Juergen Hoeller
See Also:
Serialized Form

Constructor Summary
SpringSessionContext(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory)
          Create a new SpringSessionContext for the given Hibernate SessionFactory.
 
Method Summary
 org.hibernate.Session currentSession()
          Retrieve the Spring-managed Session for the current thread, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringSessionContext

public SpringSessionContext(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory)
Create a new SpringSessionContext for the given Hibernate SessionFactory.

Parameters:
sessionFactory - the SessionFactory to provide current Sessions for
Method Detail

currentSession

public org.hibernate.Session currentSession()
                                     throws org.hibernate.HibernateException
Retrieve the Spring-managed Session for the current thread, if any.

Specified by:
currentSession in interface org.hibernate.context.spi.CurrentSessionContext
Throws:
org.hibernate.HibernateException

Spring Framework