Enum TransactionDefinition.Propagation
- java.lang.Object
-
- java.lang.Enum<TransactionDefinition.Propagation>
-
- io.micronaut.transaction.TransactionDefinition.Propagation
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<TransactionDefinition.Propagation>
- Enclosing interface:
- TransactionDefinition
public static enum TransactionDefinition.Propagation extends java.lang.Enum<TransactionDefinition.Propagation>
Possible propagation values.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description MANDATORY
Support a current transaction; throw an exception if no current transaction exists.NESTED
Execute within a nested transaction if a current transaction exists, behave likeREQUIRED
otherwise.NEVER
Do not support a current transaction; throw an exception if a current transaction exists.NOT_SUPPORTED
Do not support a current transaction; rather always execute non-transactionally.REQUIRED
Support a current transaction; create a new one if none exists.REQUIRES_NEW
Create a new transaction, suspending the current transaction if one exists.SUPPORTS
Support a current transaction; execute non-transactionally if none exists.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TransactionDefinition.Propagation
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static TransactionDefinition.Propagation[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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 JDBCConnection
, a HibernateSession
, 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 onPROPAGATION_REQUIRED
orPROPAGATION_REQUIRES_NEW
within aPROPAGATION_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 thejavax.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 thejavax.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 likeREQUIRED
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 Detail
-
values
public static TransactionDefinition.Propagation[] 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 (TransactionDefinition.Propagation c : TransactionDefinition.Propagation.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TransactionDefinition.Propagation valueOf(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
-