public class ChainedTransactionManager extends Object implements PlatformTransactionManager
PlatformTransactionManager
implementation that orchestrates transaction creation, commits and rollbacks to a
list of delegates. Using this implementation assumes that errors causing a transaction rollback will usually happen
before the transaction completion or during the commit of the most inner PlatformTransactionManager
.
The configured instances will start transactions in the order given and commit/rollback in reverse order,
which means the PlatformTransactionManager
most likely to break the transaction should be the last
in the list configured. A PlatformTransactionManager
throwing an exception during commit will automatically
cause the remaining transaction managers to roll back instead of committing.Constructor and Description |
---|
ChainedTransactionManager(PlatformTransactionManager... transactionManagers)
Creates a new
ChainedTransactionManager delegating to the given PlatformTransactionManager s. |
Modifier and Type | Method and Description |
---|---|
void |
commit(TransactionStatus status) |
org.springframework.data.transaction.MultiTransactionStatus |
getTransaction(TransactionDefinition definition) |
void |
rollback(TransactionStatus status) |
public ChainedTransactionManager(PlatformTransactionManager... transactionManagers)
ChainedTransactionManager
delegating to the given PlatformTransactionManager
s.transactionManagers
- must not be null or empty.public org.springframework.data.transaction.MultiTransactionStatus getTransaction(@Nullable TransactionDefinition definition) throws TransactionException
getTransaction
in interface PlatformTransactionManager
TransactionException
public void commit(TransactionStatus status) throws TransactionException
commit
in interface PlatformTransactionManager
TransactionException
public void rollback(TransactionStatus status) throws TransactionException
rollback
in interface PlatformTransactionManager
TransactionException
Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.