public static enum TransactionDefinition.Propagation extends java.lang.Enum<TransactionDefinition.Propagation>
Enum Constant and 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 like
REQUIRED 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.
|
Modifier and Type | Method and 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.
|
public static final TransactionDefinition.Propagation REQUIRED
This is typically the default setting of a transaction definition, and typically defines a transaction synchronization scope.
public static final TransactionDefinition.Propagation SUPPORTS
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").
public static final TransactionDefinition.Propagation MANDATORY
Note that transaction synchronization within a PROPAGATION_MANDATORY
scope will always be driven by the surrounding transaction.
public static final TransactionDefinition.Propagation REQUIRES_NEW
NOTE: Actual transaction suspension will not work out-of-the-box
on all transaction managers. This in particular applies to
JtaTransactionManager
,
which requires the javax.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.
public static final TransactionDefinition.Propagation NOT_SUPPORTED
NOTE: Actual transaction suspension will not work out-of-the-box
on all transaction managers. This in particular applies to
JtaTransactionManager
,
which requires the javax.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.
public static final TransactionDefinition.Propagation NEVER
Note that transaction synchronization is not available within a
PROPAGATION_NEVER
scope.
public static final TransactionDefinition.Propagation NESTED
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.
public static TransactionDefinition.Propagation[] values()
for (TransactionDefinition.Propagation c : TransactionDefinition.Propagation.values()) System.out.println(c);
public static TransactionDefinition.Propagation valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null