Class HibernateTransactionManager
java.lang.Object
io.micronaut.transaction.support.AbstractPropagatedStatusTransactionOperations<T,C>
io.micronaut.transaction.support.AbstractTransactionOperations<DefaultTransactionStatus<C>,C>
io.micronaut.transaction.support.AbstractDefaultTransactionOperations<org.hibernate.Session>
io.micronaut.transaction.hibernate.HibernateTransactionManager
- All Implemented Interfaces:
SynchronousTransactionManager<org.hibernate.Session>
,TransactionManager
,TransactionOperations<org.hibernate.Session>
@EachBean(javax.sql.DataSource.class)
@Replaces(DataSourceTransactionManager.class)
@Requires(condition=io.micronaut.transaction.hibernate.HibernateTransactionManagerCondition.class)
public final class HibernateTransactionManager
extends AbstractDefaultTransactionOperations<org.hibernate.Session>
The Hibernate transaction manager.
Partially based on https://github.com/spring-projects/spring-framework/blob/main/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Field Summary
Fields inherited from class io.micronaut.transaction.support.AbstractTransactionOperations
connectionOperations, logger, synchronousConnectionManager
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doBegin
(DefaultTransactionStatus<org.hibernate.Session> txStatus) Begin a new transaction with semantics according to the given transaction definition.protected void
doCommit
(DefaultTransactionStatus<org.hibernate.Session> tx) Perform an actual commit of the given transaction.protected void
doNestedBegin
(DefaultTransactionStatus<org.hibernate.Session> status) Alternative of theAbstractTransactionOperations.doBegin(InternalTransaction)
intended for a nested transaction.protected void
doNestedCommit
(DefaultTransactionStatus<org.hibernate.Session> status) Alternative of theAbstractTransactionOperations.doCommit(InternalTransaction)
intended for a nested transaction.protected void
doNestedRollback
(DefaultTransactionStatus<org.hibernate.Session> status) Alternative of theAbstractTransactionOperations.doRollback(InternalTransaction)
intended for a nested transaction.protected void
doRollback
(DefaultTransactionStatus<org.hibernate.Session> tx) Perform an actual rollback of the given transaction.@NonNull org.hibernate.Session
Obtains the connection for the current transaction.@io.micronaut.core.annotation.NonNull boolean
Check if the connection exists.Methods inherited from class io.micronaut.transaction.support.AbstractDefaultTransactionOperations
createExistingTransactionStatus, createNewTransactionStatus, createNoTxTransactionStatus
Methods inherited from class io.micronaut.transaction.support.AbstractTransactionOperations
commit, determineTimeout, doExecute, doResume, doSuspend, getConnectionDefinition, getTransaction, rollback, suspend
Methods inherited from class io.micronaut.transaction.support.AbstractPropagatedStatusTransactionOperations
execute, extendCurrentPropagatedContext, findTransactionStatus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.transaction.TransactionOperations
execute, executeRead, executeWrite, findTransactionStatus
-
Method Details
-
doBegin
Description copied from class:AbstractTransactionOperations
Begin a new transaction with semantics according to the given transaction definition. Does not have to care about applying the propagation behavior, as this has already been handled by this abstract manager.This method gets called when the transaction manager has decided to actually start a new transaction. Either there wasn't any transaction before, or the previous transaction has been suspended.
- Specified by:
doBegin
in classAbstractTransactionOperations<DefaultTransactionStatus<org.hibernate.Session>,
org.hibernate.Session> - Parameters:
txStatus
- The transaction
-
doCommit
Description copied from class:AbstractTransactionOperations
Perform an actual commit of the given transaction.An implementation does not need to check the "new transaction" flag or the rollback-only flag; this will already have been handled before. Usually, a straight commit will be performed on the transaction object contained in the passed-in status.
- Specified by:
doCommit
in classAbstractTransactionOperations<DefaultTransactionStatus<org.hibernate.Session>,
org.hibernate.Session> - Parameters:
tx
- The transaction
-
doRollback
Description copied from class:AbstractTransactionOperations
Perform an actual rollback of the given transaction.An implementation does not need to check the "new transaction" flag; this will already have been handled before. Usually, a straight rollback will be performed on the transaction object contained in the passed-in status.
- Specified by:
doRollback
in classAbstractTransactionOperations<DefaultTransactionStatus<org.hibernate.Session>,
org.hibernate.Session> - Parameters:
tx
- The transaction
-
doNestedBegin
Description copied from class:AbstractTransactionOperations
Alternative of theAbstractTransactionOperations.doBegin(InternalTransaction)
intended for a nested transaction.- Overrides:
doNestedBegin
in classAbstractTransactionOperations<DefaultTransactionStatus<org.hibernate.Session>,
org.hibernate.Session> - Parameters:
status
- The transaction
-
doNestedCommit
Description copied from class:AbstractTransactionOperations
Alternative of theAbstractTransactionOperations.doCommit(InternalTransaction)
intended for a nested transaction.- Overrides:
doNestedCommit
in classAbstractTransactionOperations<DefaultTransactionStatus<org.hibernate.Session>,
org.hibernate.Session> - Parameters:
status
- The transaction
-
doNestedRollback
Description copied from class:AbstractTransactionOperations
Alternative of theAbstractTransactionOperations.doRollback(InternalTransaction)
intended for a nested transaction.- Overrides:
doNestedRollback
in classAbstractTransactionOperations<DefaultTransactionStatus<org.hibernate.Session>,
org.hibernate.Session> - Parameters:
status
- The transaction
-
getConnection
@NonNull public @NonNull org.hibernate.Session getConnection()Description copied from interface:TransactionOperations
Obtains the connection for the current transaction.- Returns:
- The connection
-
hasConnection
@NonNull public @io.micronaut.core.annotation.NonNull boolean hasConnection()Description copied from interface:TransactionOperations
Check if the connection exists.- Specified by:
hasConnection
in interfaceTransactionOperations<org.hibernate.Session>
- Overrides:
hasConnection
in classAbstractTransactionOperations<DefaultTransactionStatus<org.hibernate.Session>,
org.hibernate.Session> - Returns:
- True if transaction exists
-