Interface Transaction.Callback

All Known Implementing Classes:
PermazenTransactionManager.TransactionSynchronizationCallback, Transaction.CallbackAdapter
Enclosing class:
Transaction

public static interface Transaction.Callback
Callback interface for notification of transaction completion events. Callbacks are registered with a transaction via Transaction.addCallback(), and are executed in the order registered, in the same thread that just committed (or rolled back) the transaction.

Modeled after Spring's TransactionSynchronization interface.

See Also:
  • Method Details

    • beforeCommit

      void beforeCommit(boolean readOnly)
      Invoked before transaction commit (and before beforeCompletion()). This method is invoked when a transaction is intended to be committed; it may however still be rolled back.

      Any exceptions thrown will result in a transaction rollback and be propagated to the caller.

      Parameters:
      readOnly - true if the transaction is marked read-only
    • beforeCompletion

      void beforeCompletion()
      Invoked before transaction completion in any case (but after any beforeCommit()). This method is invoked whether the transaction is going to be committed or rolled back, and is invoked even if beforeCommit() throws an exception. Typically used to clean up resources before transaction completion.

      Any exceptions thrown will be logged but will not propagate to the caller.

    • afterCommit

      void afterCommit()
      Invoked after successful transaction commit (and before afterCompletion()).

      Any exceptions thrown will propagate to the caller.

    • afterCompletion

      void afterCompletion(boolean committed)
      Invoked after transaction completion (but after any afterCommit()). This method is invoked in any case, whether the transaction was committed or rolled back. Typically used to clean up resources after transaction completion.

      Any exceptions thrown will be logged but will not propagate to the caller.

      Parameters:
      committed - true if transaction was commited, false if transaction was rolled back