org.springframework.transaction.event

## Enum TransactionPhase

- java.lang.Object
- - java.lang.Enum<TransactionPhase>
  - - org.springframework.transaction.event.TransactionPhase

- All Implemented Interfaces:
    Serializable, Comparable<TransactionPhase>

      public enum TransactionPhase
      extends Enum<TransactionPhase>

  The phase in which a transactional event listener applies.
  Since:
    4.2
  Author:
    Stephane Nicoll, Juergen Hoeller, Sam Brannen
  See Also:
    `TransactionalEventListener.phase()`, `TransactionalApplicationListener.getTransactionPhase()`, `TransactionalApplicationListener.forPayload(TransactionPhase, Consumer)`

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `AFTER_COMMIT` Handle the event after the commit has completed successfully.
    `AFTER_COMPLETION` Handle the event after the transaction has completed.
    `AFTER_ROLLBACK` Handle the event if the transaction has rolled back.
    `BEFORE_COMMIT` Handle the event before transaction commit.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static TransactionPhase` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static TransactionPhase[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### BEFORE_COMMIT

          public static final TransactionPhase BEFORE_COMMIT

      Handle the event before transaction commit.
      See Also:
        `TransactionSynchronization.beforeCommit(boolean)`

    - #### AFTER_COMMIT

          public static final TransactionPhase AFTER_COMMIT

      Handle the event after the commit has completed successfully.

      Note: This is a specialization of `AFTER_COMPLETION` and therefore executes in the same sequence of events as `AFTER_COMPLETION` (and not in `TransactionSynchronization.afterCommit()`).

      Interactions with the underlying transactional resource will not be committed in this phase. See `TransactionSynchronization.afterCompletion(int)` for details.

      See Also:
        `TransactionSynchronization.afterCompletion(int)`, `TransactionSynchronization.STATUS_COMMITTED`

    - #### AFTER_ROLLBACK

          public static final TransactionPhase AFTER_ROLLBACK

      Handle the event if the transaction has rolled back.

      Note: This is a specialization of `AFTER_COMPLETION` and therefore executes in the same sequence of events as `AFTER_COMPLETION`.

      Interactions with the underlying transactional resource will not be committed in this phase. See `TransactionSynchronization.afterCompletion(int)` for details.

      See Also:
        `TransactionSynchronization.afterCompletion(int)`, `TransactionSynchronization.STATUS_ROLLED_BACK`

    - #### AFTER_COMPLETION

          public static final TransactionPhase AFTER_COMPLETION

      Handle the event after the transaction has completed.

      For more fine-grained events, use `AFTER_COMMIT` or `AFTER_ROLLBACK` to intercept transaction commit or rollback, respectively.

      Interactions with the underlying transactional resource will not be committed in this phase. See `TransactionSynchronization.afterCompletion(int)` for details.

      See Also:
        `TransactionSynchronization.afterCompletion(int)`

  - ### Method Detail

    - #### values

          public static TransactionPhase[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (TransactionPhase c : TransactionPhase.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static TransactionPhase valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null