本文介绍了@Transactional(传播= Propagation.REQUIRED)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有一个人能解释一下这个注释做,什么时候我们使用它:

if some one can explain what this annotation do and when exactly we use it :

@Transactional(propagation=Propagation.REQUIRED)

感谢

推荐答案

在传播设置是PROPAGATION_REQUIRED,对在其上应用设定每种方法创建一个逻辑事务范围。每一个这样的逻辑事务范围可单独决定只回退状态,与外部事务的范围是从内部事务范围逻辑上独立的。当然,在标准PROPAGATION_REQUIRED行为的情况下,所有这些范围将被映射到相同的物理事务。所以在内部事务范围仅回滚标志设置不影响外部事务的机会真正承诺(如你希望它)。

When the propagation setting is PROPAGATION_REQUIRED, a logical transaction scope is created for each method upon which the setting is applied. Each such logical transaction scope can determine rollback-only status individually, with an outer transaction scope being logically independent from the inner transaction scope. Of course, in case of standard PROPAGATION_REQUIRED behavior, all these scopes will be mapped to the same physical transaction. So a rollback-only marker set in the inner transaction scope does affect the outer transaction's chance to actually commit (as you would expect it to).

http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/transaction.html

这篇关于@Transactional(传播= Propagation.REQUIRED)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 07:04
查看更多