Enum Class TransactionDefinition.Propagation
- All Implemented Interfaces:
Serializable
,Comparable<TransactionDefinition.Propagation>
,Constable
- Enclosing interface:
- TransactionDefinition
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionSupport a current transaction; throw an exception if no current transaction exists.Execute within a nested transaction if a current transaction exists, behave likeREQUIRED
otherwise.Do not support a current transaction; throw an exception if a current transaction exists.Do not support a current transaction; rather always execute non-transactionally.Support a current transaction; create a new one if none exists.Create a new transaction, suspending the current transaction if one exists.Support a current transaction; execute non-transactionally if none exists. -
Method Summary
Modifier and TypeMethodDescriptionReturns the enum constant of this class with the specified name.static TransactionDefinition.Propagation[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
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
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
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 thejakarta.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
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 thejakarta.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
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
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 Details
-
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
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 nameNullPointerException
- if the argument is null
-