Top Description Fields Constructors Methods
org.springframework.orm.hibernate5

public Class SpringSessionContext

extends Object
implements CurrentSessionContext
Class Inheritance
All Implemented Interfaces
org.hibernate.context.spi.CurrentSessionContext, java.io.Serializable
Annotations
@SuppressWarnings:serial
Imports
jakarta.transaction.Status, .SystemException, .TransactionManager, org.apache.commons.logging.LogFactory, org.hibernate.FlushMode, .HibernateException, .Session, org.hibernate.context.spi.CurrentSessionContext, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform, org.springframework.lang.Nullable, org.springframework.orm.jpa.EntityManagerHolder, org.springframework.transaction.support.TransactionSynchronizationManager

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.

Author
Juergen Hoeller
Since
4.2

Field Summary

Modifier and TypeField and Description
private CurrentSessionContext
private final SessionFactoryImplementor
sessionFactory

References Deprecated SessionFactoryImplementor is deprecated or references (maybe indirectly) at least one deprecated element.
private TransactionManager

Constructor Summary

AccessConstructor and Description
public
SpringSessionContext(SessionFactoryImplementor
the SessionFactory to provide current Sessions for
sessionFactory
)
References Deprecated SessionFactoryImplementor is deprecated or references (maybe indirectly) at least one deprecated element.

Create a new SpringSessionContext for the given Hibernate SessionFactory.

Method Summary

Modifier and TypeMethod and Description
public Session
currentSession()

Implements org.hibernate.context.spi.CurrentSessionContext.currentSession.

References Deprecated Session is deprecated or references (maybe indirectly) at least one deprecated element.

Retrieve the Spring-managed Session for the current thread, if any.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

jtaSessionContextback to summary
private CurrentSessionContext jtaSessionContext
Annotations
@Nullable
sessionFactoryback to summary
private final SessionFactoryImplementor sessionFactory

References Deprecated

SessionFactoryImplementor is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

transactionManagerback to summary
private TransactionManager transactionManager
Annotations
@Nullable

Constructor Detail

SpringSessionContextback to summary
public SpringSessionContext(SessionFactoryImplementor sessionFactory)

References Deprecated

SessionFactoryImplementor is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Create a new SpringSessionContext for the given Hibernate SessionFactory.

Parameters
sessionFactory:SessionFactoryImplementor

the SessionFactory to provide current Sessions for

Method Detail

currentSessionback to summary
public Session currentSession() throws HibernateException

Implements org.hibernate.context.spi.CurrentSessionContext.currentSession.

References Deprecated

Session is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Retrieve the Spring-managed Session for the current thread, if any.

Returns:Session

Doc from org.hibernate.context.spi.CurrentSessionContext.currentSession.

The current session.

Annotations
@Override
Exceptions
HibernateException:

Doc from org.hibernate.context.spi.CurrentSessionContext.currentSession.

Typically indicates an issue locating or creating the current session.