public class DefaultTransactionAttribute extends DefaultTransactionDefinition implements TransactionAttribute
PREFIX_ISOLATION, PREFIX_PROPAGATION, PREFIX_TIMEOUT, READ_ONLY_MARKER
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 |
---|
DefaultTransactionAttribute()
Create a new DefaultTransactionAttribute, with default settings.
|
DefaultTransactionAttribute(int propagationBehavior)
Create a new DefaultTransactionAttribute with the given
propagation behavior.
|
DefaultTransactionAttribute(TransactionAttribute other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.StringBuilder |
getAttributeDescription()
Return an identifying description for this transaction attribute.
|
java.lang.String |
getDescriptor()
Return a descriptor for this transaction attribute,
or
null if none. |
java.lang.String |
getQualifier()
Return a qualifier value associated with this transaction attribute.
|
boolean |
rollbackOn(java.lang.Throwable ex)
The default behavior is as with EJB: rollback on unchecked exception
(
RuntimeException ), assuming an unexpected outcome outside of any
business rules. |
void |
setDescriptor(java.lang.String descriptor)
Set a descriptor for this transaction attribute,
e.g.
|
void |
setQualifier(java.lang.String qualifier)
Associate a qualifier value with this transaction attribute.
|
equals, getDefinitionDescription, getIsolationLevel, getName, getPropagationBehavior, getTimeout, hashCode, isReadOnly, setIsolationLevel, setIsolationLevelName, setName, setPropagationBehavior, setPropagationBehaviorName, setReadOnly, setTimeout, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getIsolationLevel, getName, getPropagationBehavior, getTimeout, isReadOnly
public DefaultTransactionAttribute()
public DefaultTransactionAttribute(TransactionAttribute other)
public DefaultTransactionAttribute(int propagationBehavior)
propagationBehavior
- one of the propagation constants in the
TransactionDefinition interfaceDefaultTransactionDefinition.setIsolationLevel(int)
,
DefaultTransactionDefinition.setTimeout(int)
,
DefaultTransactionDefinition.setReadOnly(boolean)
public void setQualifier(java.lang.String qualifier)
This may be used for choosing a corresponding transaction manager to process this specific transaction.
@Nullable public java.lang.String getQualifier()
getQualifier
in interface TransactionAttribute
public void setDescriptor(@Nullable java.lang.String descriptor)
@Nullable public java.lang.String getDescriptor()
null
if none.public boolean rollbackOn(java.lang.Throwable ex)
RuntimeException
), assuming an unexpected outcome outside of any
business rules. Additionally, we also attempt to rollback on Error
which
is clearly an unexpected outcome as well. By contrast, a checked exception is
considered a business exception and therefore a regular expected outcome of the
transactional business method, i.e. a kind of alternative return value which
still allows for regular completion of resource operations.
This is largely consistent with TransactionTemplate's default behavior, except that TransactionTemplate also rolls back on undeclared checked exceptions (a corner case). For declarative transactions, we expect checked exceptions to be intentionally declared as business exceptions, leading to a commit by default.
rollbackOn
in interface TransactionAttribute
ex
- the exception to evaluateTransactionTemplate.execute(org.springframework.transaction.support.TransactionCallback<T>)
protected final java.lang.StringBuilder getAttributeDescription()
Available to subclasses, for inclusion in their toString()
result.