Class springSessionContext
java.lang.Object
org.springframework.orm.jpa.hibernate.springSessionContext
- All Implemented Interfaces:
Serializable, CurrentSessionContext
Implementation of Hibernate's
CurrentSessionContext interface
that provides 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:
- 7.0
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionspringSessionContext(SessionFactoryImplementor sessionFactory) Create a new springSessionContext for the given Hibernate SessionFactory. -
Method Summary
Modifier and TypeMethodDescriptionRetrieve the spring-managed Session for the current thread, if any.static StatelessSessioncurrentStatelessSession(SessionFactory sessionFactory) Obtain aStatelessSessionfor the current transaction.
-
Constructor Details
-
springSessionContext
Create a new springSessionContext for the given Hibernate SessionFactory.- Parameters:
sessionFactory- the SessionFactory to provide current Sessions for
-
-
Method Details
-
currentSession
Retrieve the spring-managed Session for the current thread, if any.- Specified by:
currentSessionin interfaceCurrentSessionContext- Throws:
HibernateException
-
currentStatelessSession
Obtain aStatelessSessionfor the current transaction.- Parameters:
sessionFactory- the target SessionFactory- Returns:
- the current StatelessSession
-