Enum Class TransactionDefinition.Propagation

java.lang.Object
java.lang.Enum<TransactionDefinition.Propagation>
io.micronaut.transaction.TransactionDefinition.Propagation
All Implemented Interfaces:
Serializable, Comparable<TransactionDefinition.Propagation>, Constable
Enclosing interface:
TransactionDefinition

public static enum TransactionDefinition.Propagation extends Enum<TransactionDefinition.Propagation>
Defines what happens when a transactional unit of work starts while a transaction is, or is not, already active in the current context. The names and semantics match the transaction attributes of Jakarta Transactions (jakarta.transaction.Transactional.TxType), plus NESTED.
Since:
08.05.2003
Author:
Juergen Hoeller, graemerocher
  • Enum Constant Details

    • REQUIRED

      public static final TransactionDefinition.Propagation REQUIRED
      Join the current transaction; start a new one if none is active. This is the default.

      When the work joins an existing transaction, it shares that transaction's connection, and commit or rollback happens when the outermost transactional scope completes. A failure that causes a rollback in the joined scope marks the whole transaction rollback-only.

    • SUPPORTS

      public static final TransactionDefinition.Propagation SUPPORTS
      Join the current transaction if one is active; otherwise run without a transaction.

      Without a transaction, the statements are not grouped into a transaction, but the same connection (or session) is still used for the whole scope.

    • MANDATORY

      public static final TransactionDefinition.Propagation MANDATORY
      Join the current transaction; fail with IllegalTransactionStateException if none is active.
    • REQUIRES_NEW

      public static final TransactionDefinition.Propagation REQUIRES_NEW
      Always start a new, independent transaction on a new connection, suspending the current transaction (if any) until the new one completes. The new transaction commits or rolls back independently of the suspended one, and has its own synchronizations.
    • NOT_SUPPORTED

      public static final TransactionDefinition.Propagation NOT_SUPPORTED
      Run without a transaction, suspending the current transaction (if any) until the work completes.
    • NEVER

      public static final TransactionDefinition.Propagation NEVER
      Run without a transaction; fail with a TransactionUsageException if a transaction is active.
    • NESTED

      public static final TransactionDefinition.Propagation NESTED
      If a transaction is active, run in a nested transaction backed by a savepoint of the current transaction; otherwise behave like REQUIRED.

      Rolling back the nested transaction only rolls back to the savepoint, so the outer transaction can continue; committing it releases the savepoint, and its changes become permanent only when the outer transaction commits. Nested transactions require a transaction manager that supports savepoints, such as the JDBC and Hibernate transaction managers, and fail with NestedTransactionNotSupportedException otherwise.

  • Method Details

    • values

      public static TransactionDefinition.Propagation[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TransactionDefinition.Propagation valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null