public class DefaultTransactionAttribute extends DefaultTransactionDefinition implements TransactionAttribute
PREFIX_ISOLATION, PREFIX_PROPAGATION, PREFIX_TIMEOUT, READ_ONLY_MARKERISOLATION_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 StringBuilder |
getAttributeDescription()
Return an identifying description for this transaction attribute.
|
String |
getDescriptor()
Return a descriptor for this transaction attribute,
or
null if none. |
Collection<String> |
getLabels()
Return labels associated with this transaction attribute.
|
String |
getQualifier()
Return a qualifier value associated with this transaction attribute.
|
String |
getTimeoutString()
Return the timeout to apply, if any,
as a String value that resolves to a number of seconds.
|
void |
resolveAttributeStrings(org.springframework.util.StringValueResolver resolver)
Resolve attribute values that are defined as resolvable Strings:
setTimeoutString(java.lang.String), setQualifier(java.lang.String), setLabels(java.util.Collection<java.lang.String>). |
boolean |
rollbackOn(Throwable ex)
The default behavior is as with EJB: rollback on unchecked exception
(
RuntimeException), assuming an unexpected outcome outside any
business rules. |
void |
setDescriptor(String descriptor)
Set a descriptor for this transaction attribute,
e.g.
|
void |
setLabels(Collection<String> labels)
Associate one or more labels with this transaction attribute.
|
void |
setQualifier(String qualifier)
Associate a qualifier value with this transaction attribute.
|
void |
setTimeoutString(String timeoutString)
Set the timeout to apply, if any,
as a String value that resolves to a number of seconds.
|
equals, getDefinitionDescription, getIsolationLevel, getName, getPropagationBehavior, getTimeout, hashCode, isReadOnly, setIsolationLevel, setIsolationLevelName, setName, setPropagationBehavior, setPropagationBehaviorName, setReadOnly, setTimeout, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetIsolationLevel, getName, getPropagationBehavior, getTimeout, isReadOnly, withDefaultspublic 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 setDescriptor(@Nullable
String descriptor)
@Nullable public String getDescriptor()
null if none.public void setTimeoutString(@Nullable
String timeoutString)
@Nullable public String getTimeoutString()
public void setQualifier(@Nullable
String qualifier)
This may be used for choosing a corresponding transaction manager to process this specific transaction.
resolveAttributeStrings(org.springframework.util.StringValueResolver)@Nullable public String getQualifier()
getQualifier in interface TransactionAttributepublic void setLabels(Collection<String> labels)
This may be used for applying specific transactional behavior or follow a purely descriptive nature.
resolveAttributeStrings(org.springframework.util.StringValueResolver)public Collection<String> getLabels()
TransactionAttributeThis may be used for applying specific transactional behavior or follow a purely descriptive nature.
getLabels in interface TransactionAttributepublic boolean rollbackOn(Throwable ex)
RuntimeException), assuming an unexpected outcome outside 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 TransactionAttributeex - the exception to evaluateTransactionTemplate.execute(org.springframework.transaction.support.TransactionCallback<T>)public void resolveAttributeStrings(@Nullable
org.springframework.util.StringValueResolver resolver)
setTimeoutString(java.lang.String), setQualifier(java.lang.String), setLabels(java.util.Collection<java.lang.String>).
This is typically used for resolving "${...}" placeholders.resolver - the embedded value resolver to apply, if anyprotected final StringBuilder getAttributeDescription()
Available to subclasses, for inclusion in their toString() result.