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>
Possible propagation values.
  • Enum Constant Details

    • REQUIRED

      public static final TransactionDefinition.Propagation REQUIRED
      Support a current transaction; create a new one if none exists. Analogous to the EJB transaction attribute of the same name.

      This is typically the default setting of a transaction definition, and typically defines a transaction synchronization scope.

    • SUPPORTS

      public static final TransactionDefinition.Propagation SUPPORTS
      Support a current transaction; execute non-transactionally if none exists. Analogous to the EJB transaction attribute of the same name.

      NOTE: For transaction managers with transaction synchronization, PROPAGATION_SUPPORTS is slightly different from no transaction at all, as it defines a transaction scope that synchronization might apply to. As a consequence, the same resources (a JDBC Connection, a Hibernate Session, etc.) will be shared for the entire specified scope. Note that the exact behavior depends on the actual synchronization configuration of the transaction manager!

      In general, use PROPAGATION_SUPPORTS with care! In particular, do not rely on PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW within a PROPAGATION_SUPPORTS scope (which may lead to synchronization conflicts at runtime). If such nesting is unavoidable, make sure to configure your transaction manager appropriately (typically switching to "synchronization on actual transaction").

    • MANDATORY

      public static final TransactionDefinition.Propagation MANDATORY
      Support a current transaction; throw an exception if no current transaction exists. Analogous to the EJB transaction attribute of the same name.

      Note that transaction synchronization within a PROPAGATION_MANDATORY scope will always be driven by the surrounding transaction.

    • REQUIRES_NEW

      public static final TransactionDefinition.Propagation REQUIRES_NEW
      Create a new transaction, suspending the current transaction if one exists. Analogous to the EJB transaction attribute of the same name.

      NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to JtaTransactionManager, which requires the jakarta.transaction.TransactionManager to be made available it to it (which is server-specific in standard Java EE).

      A PROPAGATION_REQUIRES_NEW scope always defines its own transaction synchronizations. Existing synchronizations will be suspended and resumed appropriately.

    • NOT_SUPPORTED

      public static final TransactionDefinition.Propagation NOT_SUPPORTED
      Do not support a current transaction; rather always execute non-transactionally. Analogous to the EJB transaction attribute of the same name.

      NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to JtaTransactionManager, which requires the jakarta.transaction.TransactionManager to be made available it to it (which is server-specific in standard Java EE).

      Note that transaction synchronization is not available within a PROPAGATION_NOT_SUPPORTED scope. Existing synchronizations will be suspended and resumed appropriately.

    • NEVER

      public static final TransactionDefinition.Propagation NEVER
      Do not support a current transaction; throw an exception if a current transaction exists. Analogous to the EJB transaction attribute of the same name.

      Note that transaction synchronization is not available within a PROPAGATION_NEVER scope.

    • NESTED

      public static final TransactionDefinition.Propagation NESTED
      Execute within a nested transaction if a current transaction exists, behave like REQUIRED otherwise. There is no analogous feature in EJB.

      NOTE: Actual creation of a nested transaction will only work on specific transaction managers. Out of the box, this only applies to JDBC when working on a JDBC 3.0 driver. Some JTA providers might support nested transactions as well.

  • 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