类 RuleBasedTransactionAttribute
- java.lang.Object
- org.springframework.transaction.support.DefaultTransactionDefinition
- org.springframework.transaction.interceptor.DefaultTransactionAttribute
- org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
public class RuleBasedTransactionAttribute extends DefaultTransactionAttribute implements Serializable
TransactionAttribute implementation that works out whether a given exception should cause transaction rollback by applying a number of rollback rules, both positive and negative. If no rules are relevant to the exception, it behaves like DefaultTransactionAttribute (rolling back on runtime exceptions).TransactionAttributeEditor
creates objects of this class.- 从以下版本开始:
- 09.04.2003
- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
TransactionAttributeEditor
, 序列化表格
字段概要
字段 修饰符和类型 字段 说明 static String
PREFIX_COMMIT_RULE
Prefix for commit-on-exception rules in description stringsstatic String
PREFIX_ROLLBACK_RULE
Prefix for rollback-on-exception rules in description strings从类继承的字段 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
构造器概要
构造器 构造器 说明 RuleBasedTransactionAttribute()
Create a new RuleBasedTransactionAttribute, with default settings.RuleBasedTransactionAttribute(int propagationBehavior, List<RollbackRuleAttribute> rollbackRules)
Create a new DefaultTransactionAttribute with the given propagation behavior.RuleBasedTransactionAttribute(RuleBasedTransactionAttribute other)
Copy constructor.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 List<RollbackRuleAttribute>
getRollbackRules()
Return the list ofRollbackRuleAttribute
objects (nevernull
).boolean
rollbackOn(Throwable ex)
Winning rule is the shallowest rule (that is, the closest in the inheritance hierarchy to the exception).void
setRollbackRules(List<RollbackRuleAttribute> rollbackRules)
Set the list ofRollbackRuleAttribute
objects (and/orNoRollbackRuleAttribute
objects) to apply.String
toString()
Return an identifying description for this transaction definition.从类继承的方法 org.springframework.transaction.interceptor.DefaultTransactionAttribute
getAttributeDescription, getDescriptor, getQualifier, setDescriptor, setQualifier
从类继承的方法 org.springframework.transaction.support.DefaultTransactionDefinition
equals, getDefinitionDescription, getIsolationLevel, getName, getPropagationBehavior, getTimeout, hashCode, isReadOnly, setIsolationLevel, setIsolationLevelName, setName, setPropagationBehavior, setPropagationBehaviorName, setReadOnly, setTimeout
从接口继承的方法 org.springframework.transaction.TransactionDefinition
getIsolationLevel, getName, getPropagationBehavior, getTimeout, isReadOnly
字段详细资料
PREFIX_ROLLBACK_RULE
public static final String PREFIX_ROLLBACK_RULE
Prefix for rollback-on-exception rules in description strings- 另请参阅:
- 常量字段值
PREFIX_COMMIT_RULE
public static final String PREFIX_COMMIT_RULE
Prefix for commit-on-exception rules in description strings- 另请参阅:
- 常量字段值
构造器详细资料
RuleBasedTransactionAttribute
public RuleBasedTransactionAttribute()
Create a new RuleBasedTransactionAttribute, with default settings. Can be modified through bean property setters.- 另请参阅:
DefaultTransactionDefinition.setPropagationBehavior(int)
,DefaultTransactionDefinition.setIsolationLevel(int)
,DefaultTransactionDefinition.setTimeout(int)
,DefaultTransactionDefinition.setReadOnly(boolean)
,DefaultTransactionDefinition.setName(java.lang.String)
,setRollbackRules(java.util.List<org.springframework.transaction.interceptor.RollbackRuleAttribute>)
RuleBasedTransactionAttribute
public RuleBasedTransactionAttribute(RuleBasedTransactionAttribute other)
Copy constructor. Definition can be modified through bean property setters.- 另请参阅:
DefaultTransactionDefinition.setPropagationBehavior(int)
,DefaultTransactionDefinition.setIsolationLevel(int)
,DefaultTransactionDefinition.setTimeout(int)
,DefaultTransactionDefinition.setReadOnly(boolean)
,DefaultTransactionDefinition.setName(java.lang.String)
,setRollbackRules(java.util.List<org.springframework.transaction.interceptor.RollbackRuleAttribute>)
RuleBasedTransactionAttribute
public RuleBasedTransactionAttribute(int propagationBehavior, List<RollbackRuleAttribute> rollbackRules)
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 interfacerollbackRules
- the list of RollbackRuleAttributes to apply- 另请参阅:
DefaultTransactionDefinition.setIsolationLevel(int)
,DefaultTransactionDefinition.setTimeout(int)
,DefaultTransactionDefinition.setReadOnly(boolean)
方法详细资料
setRollbackRules
public void setRollbackRules(List<RollbackRuleAttribute> rollbackRules)
Set the list ofRollbackRuleAttribute
objects (and/orNoRollbackRuleAttribute
objects) to apply.
getRollbackRules
public List<RollbackRuleAttribute> getRollbackRules()
Return the list ofRollbackRuleAttribute
objects (nevernull
).
rollbackOn
public boolean rollbackOn(Throwable ex)
Winning rule is the shallowest rule (that is, the closest in the inheritance hierarchy to the exception). If no rule applies (-1), return false.- 指定者:
rollbackOn
在接口中TransactionAttribute
- 覆盖:
rollbackOn
在类中DefaultTransactionAttribute
- 参数:
ex
- the exception to evaluate- 返回:
- whether to perform a rollback or not
- 另请参阅:
TransactionAttribute.rollbackOn(java.lang.Throwable)
toString
public String toString()
从类复制的说明:DefaultTransactionDefinition
Return an identifying description for this transaction definition.The format matches the one used by
TransactionAttributeEditor
, to be able to feedtoString
results into bean properties of typeTransactionAttribute
.Has to be overridden in subclasses for correct
equals
andhashCode
behavior. Alternatively,DefaultTransactionDefinition.equals(java.lang.Object)
andDefaultTransactionDefinition.hashCode()
can be overridden themselves.