Spring Data Core

org.springframework.data.transaction
Class ChainedTransactionManager

java.lang.Object
  extended by org.springframework.data.transaction.ChainedTransactionManager
All Implemented Interfaces:
PlatformTransactionManager

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.

Since:
1.6
Author:
Michael Hunger, Oliver Gierke

Constructor Summary
ChainedTransactionManager(PlatformTransactionManager... transactionManagers)
          Creates a new ChainedTransactionManager delegating to the given PlatformTransactionManagers.
 
Method Summary
 void commit(TransactionStatus status)
           
 org.springframework.data.transaction.MultiTransactionStatus getTransaction(TransactionDefinition definition)
           
 void rollback(TransactionStatus status)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChainedTransactionManager

public ChainedTransactionManager(PlatformTransactionManager... transactionManagers)
Creates a new ChainedTransactionManager delegating to the given PlatformTransactionManagers.

Parameters:
transactionManagers - must not be null or empty.
Method Detail

getTransaction

public org.springframework.data.transaction.MultiTransactionStatus getTransaction(TransactionDefinition definition)
                                                                           throws TransactionException
Specified by:
getTransaction in interface PlatformTransactionManager
Throws:
TransactionException

commit

public void commit(TransactionStatus status)
            throws TransactionException
Specified by:
commit in interface PlatformTransactionManager
Throws:
TransactionException

rollback

public void rollback(TransactionStatus status)
              throws TransactionException
Specified by:
rollback in interface PlatformTransactionManager
Throws:
TransactionException

Spring Data Core

Copyright © 2011-2013-2013 Pivotal. All Rights Reserved.