Class MicronautSessionContext
java.lang.Object
io.micronaut.transaction.hibernate6.MicronautSessionContext
- All Implemented Interfaces:
Serializable
,org.hibernate.context.spi.CurrentSessionContext
public final class MicronautSessionContext
extends Object
implements org.hibernate.context.spi.CurrentSessionContext
Implementation of Hibernate 3.1's
CurrentSessionContext
interface
that delegates to SessionFactoryUtils
for providing a
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:
- 4.2
- Author:
- Juergen Hoeller, graemerocher
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMicronautSessionContext
(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory) Create a new SpringSessionContext for the given Hibernate SessionFactory. -
Method Summary
Modifier and TypeMethodDescriptionorg.hibernate.Session
Retrieve the Spring-managed Session for the current thread, if any.
-
Constructor Details
-
MicronautSessionContext
public MicronautSessionContext(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 Details
-
currentSession
public org.hibernate.Session currentSession() throws org.hibernate.HibernateExceptionRetrieve the Spring-managed Session for the current thread, if any.- Specified by:
currentSession
in interfaceorg.hibernate.context.spi.CurrentSessionContext
- Throws:
org.hibernate.HibernateException
-