public abstract class DelegatingTransactionDefinition extends Object implements TransactionDefinition, Serializable
TransactionDefinition
implementation that delegates all calls to a given target
TransactionDefinition
instance. Abstract because it is meant to be subclassed,
with subclasses overriding specific methods that are not supposed to simply delegate
to the target instance.ISOLATION_DEFAULT, ISOLATION_READ_COMMITTED, ISOLATION_READ_UNCOMMITTED, ISOLATION_REPEATABLE_READ, ISOLATION_SERIALIZABLE, PROPAGATION_MANDATORY, PROPAGATION_NESTED, PROPAGATION_NEVER, PROPAGATION_NOT_SUPPORTED, PROPAGATION_REQUIRED, PROPAGATION_REQUIRES_NEW, PROPAGATION_SUPPORTS, TIMEOUT_DEFAULT
Constructor and Description |
---|
DelegatingTransactionDefinition(TransactionDefinition targetDefinition)
Create a DelegatingTransactionAttribute for the given target attribute.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
int |
getIsolationLevel()
Return the isolation level.
|
String |
getName()
Return the name of this transaction.
|
int |
getPropagationBehavior()
Return the propagation behavior.
|
int |
getTimeout()
Return the transaction timeout.
|
int |
hashCode() |
boolean |
isReadOnly()
Return whether to optimize as a read-only transaction.
|
String |
toString() |
public DelegatingTransactionDefinition(TransactionDefinition targetDefinition)
targetDefinition
- the target TransactionAttribute to delegate topublic int getPropagationBehavior()
TransactionDefinition
Must return one of the PROPAGATION_XXX
constants
defined on this interface
.
getPropagationBehavior
in interface TransactionDefinition
TransactionDefinition.PROPAGATION_REQUIRED
,
TransactionSynchronizationManager.isActualTransactionActive()
public int getIsolationLevel()
TransactionDefinition
Must return one of the ISOLATION_XXX
constants
defined on this interface
.
Only makes sense in combination with TransactionDefinition.PROPAGATION_REQUIRED
or TransactionDefinition.PROPAGATION_REQUIRES_NEW
.
Note that a transaction manager that does not support custom isolation levels
will throw an exception when given any other level than TransactionDefinition.ISOLATION_DEFAULT
.
getIsolationLevel
in interface TransactionDefinition
public int getTimeout()
TransactionDefinition
Must return a number of seconds, or TransactionDefinition.TIMEOUT_DEFAULT
.
Only makes sense in combination with TransactionDefinition.PROPAGATION_REQUIRED
or TransactionDefinition.PROPAGATION_REQUIRES_NEW
.
Note that a transaction manager that does not support timeouts will throw
an exception when given any other timeout than TransactionDefinition.TIMEOUT_DEFAULT
.
getTimeout
in interface TransactionDefinition
public boolean isReadOnly()
TransactionDefinition
The read-only flag applies to any transaction context, whether
backed by an actual resource transaction
(TransactionDefinition.PROPAGATION_REQUIRED
/TransactionDefinition.PROPAGATION_REQUIRES_NEW
) or
operating non-transactionally at the resource level
(TransactionDefinition.PROPAGATION_SUPPORTS
). In the latter case, the flag will
only apply to managed resources within the application, such as a
Hibernate Session
.
This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction.
isReadOnly
in interface TransactionDefinition
true
if the transaction is to be optimized as read-onlyTransactionSynchronization.beforeCommit(boolean)
,
TransactionSynchronizationManager.isCurrentTransactionReadOnly()
@Nullable public String getName()
TransactionDefinition
null
.
This will be used as the transaction name to be shown in a transaction monitor, if applicable (for example, WebLogic's).
In case of Spring's declarative transactions, the exposed name will be
the fully-qualified class name + "." + method name
(by default).
getName
in interface TransactionDefinition
TransactionAspectSupport
,
TransactionSynchronizationManager.getCurrentTransactionName()