类 DefaultTransactionAttribute
- java.lang.Object
- org.springframework.transaction.support.DefaultTransactionDefinition
- org.springframework.transaction.interceptor.DefaultTransactionAttribute
public class DefaultTransactionAttribute extends DefaultTransactionDefinition implements TransactionAttribute
Spring's common transaction attribute implementation. Rolls back on runtime, but not checked, exceptions by default.- 从以下版本开始:
- 16.03.2003
- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
- 序列化表格
字段概要
从类继承的字段 org.springframework.transaction.support.DefaultTransactionDefinition
PREFIX_ISOLATION, PREFIX_PROPAGATION, PREFIX_TIMEOUT, READ_ONLY_MARKER
从接口继承的字段 org.springframework.transaction.TransactionDefinition
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
构造器概要
构造器 构造器 说明 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected StringBuilder
getAttributeDescription()
Return an identifying description for this transaction attribute.String
getDescriptor()
Return a descriptor for this transaction attribute, ornull
if none.String
getQualifier()
Return a qualifier value associated with this transaction attribute.boolean
rollbackOn(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(String descriptor)
Set a descriptor for this transaction attribute, e.g. indicating where the attribute is applying.void
setQualifier(String qualifier)
Associate a qualifier value with this transaction attribute.从类继承的方法 org.springframework.transaction.support.DefaultTransactionDefinition
equals, getDefinitionDescription, getIsolationLevel, getName, getPropagationBehavior, getTimeout, hashCode, isReadOnly, setIsolationLevel, setIsolationLevelName, setName, setPropagationBehavior, setPropagationBehaviorName, setReadOnly, setTimeout, toString
从接口继承的方法 org.springframework.transaction.TransactionDefinition
getIsolationLevel, getName, getPropagationBehavior, getTimeout, isReadOnly
构造器详细资料
DefaultTransactionAttribute
public DefaultTransactionAttribute()
Create a new DefaultTransactionAttribute, with default settings. Can be modified through bean property setters.
DefaultTransactionAttribute
public DefaultTransactionAttribute(TransactionAttribute other)
Copy constructor. Definition can be modified through bean property setters.
DefaultTransactionAttribute
public DefaultTransactionAttribute(int propagationBehavior)
Create a new DefaultTransactionAttribute with the given propagation behavior. Can be modified through bean property setters.- 参数:
propagationBehavior
- one of the propagation constants in the TransactionDefinition interface- 另请参阅:
DefaultTransactionDefinition.setIsolationLevel(int)
,DefaultTransactionDefinition.setTimeout(int)
,DefaultTransactionDefinition.setReadOnly(boolean)
方法详细资料
setQualifier
public void setQualifier(String qualifier)
Associate a qualifier value with this transaction attribute.This may be used for choosing a corresponding transaction manager to process this specific transaction.
- 从以下版本开始:
- 3.0
getQualifier
public String getQualifier()
Return a qualifier value associated with this transaction attribute.- 指定者:
getQualifier
在接口中TransactionAttribute
- 从以下版本开始:
- 3.0
setDescriptor
public void setDescriptor(String descriptor)
Set a descriptor for this transaction attribute, e.g. indicating where the attribute is applying.- 从以下版本开始:
- 4.3.4
getDescriptor
public String getDescriptor()
Return a descriptor for this transaction attribute, ornull
if none.- 从以下版本开始:
- 4.3.4
rollbackOn
public boolean rollbackOn(Throwable ex)
The default behavior is as with EJB: rollback on unchecked exception (RuntimeException
), assuming an unexpected outcome outside of any business rules. Additionally, we also attempt to rollback onError
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
在接口中TransactionAttribute
- 参数:
ex
- the exception to evaluate- 返回:
- whether to perform a rollback or not
- 另请参阅:
TransactionTemplate.execute(org.springframework.transaction.support.TransactionCallback<T>)
getAttributeDescription
protected final StringBuilder getAttributeDescription()
Return an identifying description for this transaction attribute.Available to subclasses, for inclusion in their
toString()
result.