Class ChainedTransactionManager

java.lang.Object
org.springframework.data.transaction.ChainedTransactionManager
All Implemented Interfaces:
org.springframework.transaction.PlatformTransactionManager, org.springframework.transaction.TransactionManager

@Deprecated public class ChainedTransactionManager extends Object implements org.springframework.transaction.PlatformTransactionManager
Deprecated.
since 2.5
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.

As consequence, a transaction can get into a state, where the first PlatformTransactionManager has committed its transaction and a subsequent PlatformTransactionManager failed to commit its transaction (e.g. caused by an I/O error or the transactional resource failed to commit for other reasons). In that case, commit(TransactionStatus) throws a HeuristicCompletionException to indicate a partially committed transaction. Rollback isn't affected as the natural consequence of a missing commit is a rollback of a transactional resource. ChainedTransactionManager should be only used if the application can tolerate or recover from inconsistent state caused by partially committed transactions. In any other case, the use of ChainedTransactionManager is not recommended.

Instead of using ChainedTransactionManager for attaching callbacks to transaction commit (pre commit/post commit), either register a TransactionSynchronization to explicitly follow transaction cleanup with simplified semantics in case of exceptions.

Since:
1.6
Author:
Michael Hunger, Oliver Gierke, Mark Paluch
See Also:
  • TransactionSynchronization.beforeCommit(boolean)
  • TransactionSynchronization.afterCommit()
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChainedTransactionManager(org.springframework.transaction.PlatformTransactionManager... transactionManagers)
    Deprecated.
    Creates a new ChainedTransactionManager delegating to the given PlatformTransactionManagers.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commit(org.springframework.transaction.TransactionStatus status)
    Deprecated.
     
    org.springframework.data.transaction.MultiTransactionStatus
    getTransaction(org.springframework.transaction.TransactionDefinition definition)
    Deprecated.
     
    void
    rollback(org.springframework.transaction.TransactionStatus status)
    Deprecated.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ChainedTransactionManager

      public ChainedTransactionManager(org.springframework.transaction.PlatformTransactionManager... transactionManagers)
      Deprecated.
      Creates a new ChainedTransactionManager delegating to the given PlatformTransactionManagers.
      Parameters:
      transactionManagers - must not be null or empty.
  • Method Details

    • getTransaction

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

      public void commit(org.springframework.transaction.TransactionStatus status) throws org.springframework.transaction.TransactionException
      Deprecated.
      Specified by:
      commit in interface org.springframework.transaction.PlatformTransactionManager
      Throws:
      org.springframework.transaction.TransactionException
    • rollback

      public void rollback(org.springframework.transaction.TransactionStatus status) throws org.springframework.transaction.TransactionException
      Deprecated.
      Specified by:
      rollback in interface org.springframework.transaction.PlatformTransactionManager
      Throws:
      org.springframework.transaction.TransactionException