Class SessionHolder
- java.lang.Object
-
- io.micronaut.transaction.support.ResourceHolderSupport
-
- io.micronaut.transaction.jpa.EntityManagerHolder
-
- io.micronaut.transaction.hibernate5.SessionHolder
-
- All Implemented Interfaces:
ResourceHolder
public class SessionHolder extends EntityManagerHolder
Resource holder wrapping a HibernateSession
(plus an optionalTransaction
).HibernateTransactionManager
binds instances of this class to the thread, for a givenSessionFactory
. ExtendsEntityManagerHolder
as of 5.1, automatically exposing anEntityManager
handle on Hibernate 5.2+.Note: This is an SPI class, not intended to be used by applications.
- Since:
- 4.2
- Author:
- Juergen Hoeller
- See Also:
HibernateTransactionManager
,SessionFactoryUtils
-
-
Constructor Summary
Constructors Constructor Description SessionHolder(org.hibernate.Session session)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the transactional state of this resource holder.org.hibernate.FlushMode
getPreviousFlushMode()
org.hibernate.Session
getSession()
org.hibernate.Transaction
getTransaction()
void
setPreviousFlushMode(org.hibernate.FlushMode previousFlushMode)
void
setTransaction(org.hibernate.Transaction transaction)
Set the associated transaction.-
Methods inherited from class io.micronaut.transaction.jpa.EntityManagerHolder
getEntityManager, getSavepointManager, isTransactionActive, setSavepointManager, setTransactionActive
-
Methods inherited from class io.micronaut.transaction.support.ResourceHolderSupport
getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeout, setTimeoutInMillis, unbound
-
-
-
-
Method Detail
-
getSession
public org.hibernate.Session getSession()
- Returns:
- Get the associated session
-
setTransaction
public void setTransaction(@Nullable org.hibernate.Transaction transaction)
Set the associated transaction.- Parameters:
transaction
- The transaction
-
getTransaction
@Nullable public org.hibernate.Transaction getTransaction()
- Returns:
- Get the current transaction.
-
setPreviousFlushMode
public void setPreviousFlushMode(@Nullable org.hibernate.FlushMode previousFlushMode)
- Parameters:
previousFlushMode
- The previous flush mode
-
getPreviousFlushMode
@Nullable public org.hibernate.FlushMode getPreviousFlushMode()
- Returns:
- The the previous flush mode
-
clear
public void clear()
Description copied from class:ResourceHolderSupport
Clear the transactional state of this resource holder.- Overrides:
clear
in classEntityManagerHolder
-
-