java.lang.Object | |
↳ | org.springframework.transaction.support.DefaultTransactionDefinition |
Known Direct Subclasses |
Known Indirect Subclasses |
Default implementation of the TransactionDefinition
interface,
offering bean-style configuration and sensible default values
(PROPAGATION_REQUIRED, ISOLATION_DEFAULT, TIMEOUT_DEFAULT, readOnly=false).
Base class for both TransactionTemplate
and
DefaultTransactionAttribute
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | PREFIX_ISOLATION | Prefix for the isolation constants defined in TransactionDefinition | |||||||||
String | PREFIX_PROPAGATION | Prefix for the propagation constants defined in TransactionDefinition | |||||||||
String | PREFIX_TIMEOUT | Prefix for transaction timeout values in description strings | |||||||||
String | READ_ONLY_MARKER | Marker for read-only transactions in description strings |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.transaction.TransactionDefinition
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new DefaultTransactionDefinition, with default settings.
| |||||||||||
Copy constructor.
| |||||||||||
Create a new DefaultTransactionDefinition with the the given
propagation behavior.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This implementation compares the
toString() results. | |||||||||||
Return the isolation level.
| |||||||||||
Return the name of this transaction.
| |||||||||||
Return the propagation behavior.
| |||||||||||
Return the transaction timeout.
| |||||||||||
This implementation returns
toString() 's hash code. | |||||||||||
Return whether to optimize as a read-only transaction.
| |||||||||||
Set the isolation level.
| |||||||||||
Set the isolation level by the name of the corresponding constant in
TransactionDefinition, e.g.
| |||||||||||
Set the name of this transaction.
| |||||||||||
Set the propagation behavior.
| |||||||||||
Set the propagation behavior by the name of the corresponding constant in
TransactionDefinition, e.g.
| |||||||||||
Set whether to optimize as read-only transaction.
| |||||||||||
Set the timeout to apply, as number of seconds.
| |||||||||||
Return an identifying description for this transaction definition.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return an identifying description for this transaction definition.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.transaction.TransactionDefinition
|
Prefix for the isolation constants defined in TransactionDefinition
Prefix for the propagation constants defined in TransactionDefinition
Prefix for transaction timeout values in description strings
Marker for read-only transactions in description strings
Create a new DefaultTransactionDefinition, with default settings. Can be modified through bean property setters.
Copy constructor. Definition can be modified through bean property setters.
Create a new DefaultTransactionDefinition with the the given propagation behavior. Can be modified through bean property setters.
propagationBehavior | one of the propagation constants in the TransactionDefinition interface |
---|
Return the isolation level.
Must return one of the ISOLATION_XXX
constants
defined on this interface
.
Only makes sense in combination with PROPAGATION_REQUIRED
or 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 ISOLATION_DEFAULT
.
Return the name of this transaction. Can be 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).
Return the propagation behavior.
Must return one of the PROPAGATION_XXX
constants
defined on this interface
.
Return the transaction timeout.
Must return a number of seconds, or TIMEOUT_DEFAULT
.
Only makes sense in combination with PROPAGATION_REQUIRED
or PROPAGATION_REQUIRES_NEW
.
Note that a transaction manager that does not support timeouts will throw
an exception when given any other timeout than TIMEOUT_DEFAULT
.
Return whether to optimize as a read-only transaction.
The read-only flag applies to any transaction context, whether
backed by an actual resource transaction
(PROPAGATION_REQUIRED
/PROPAGATION_REQUIRES_NEW
) or
operating non-transactionally at the resource level
(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.
true
if the transaction is to be optimized as read-only Set the isolation level. Must be one of the isolation constants in the TransactionDefinition interface. Default is ISOLATION_DEFAULT.
IllegalArgumentException | if the supplied value is not
one of the ISOLATION_ constants |
---|
Set the isolation level by the name of the corresponding constant in TransactionDefinition, e.g. "ISOLATION_DEFAULT".
constantName | name of the constant |
---|
IllegalArgumentException | if the supplied value is not resolvable
to one of the ISOLATION_ constants or is null |
---|
Set the name of this transaction. Default is none.
This will be used as transaction name to be shown in a transaction monitor, if applicable (for example, WebLogic's).
Set the propagation behavior. Must be one of the propagation constants in the TransactionDefinition interface. Default is PROPAGATION_REQUIRED.
IllegalArgumentException | if the supplied value is not
one of the PROPAGATION_ constants |
---|
Set the propagation behavior by the name of the corresponding constant in TransactionDefinition, e.g. "PROPAGATION_REQUIRED".
constantName | name of the constant |
---|
IllegalArgumentException | if the supplied value is not resolvable
to one of the PROPAGATION_ constants or is null |
---|
Set whether to optimize as read-only transaction. Default is "false".
Set the timeout to apply, as number of seconds. Default is TIMEOUT_DEFAULT (-1).
Return an identifying description for this transaction definition.
The format matches the one used by
TransactionAttributeEditor
,
to be able to feed toString
results into bean properties of type
TransactionAttribute
.
Has to be overridden in subclasses for correct equals
and hashCode
behavior. Alternatively, equals(Object)
and hashCode()
can be overridden themselves.
Return an identifying description for this transaction definition.
Available to subclasses, for inclusion in their toString()
result.