问题描述
我无法理解 PROPAGATION_REQUIRES_NEW
和 PROPAGATION_NESTED
传播政策之间的行为差异。在我看来,在这两种情况下,当前进程都是回滚的,而不是整个事务。任何线索?
I can't understand the behavior difference between the PROPAGATION_REQUIRES_NEW
and PROPAGATION_NESTED
propagation policies. It seems to me that in both cases, the current process is rollbacked but not the whole transaction. Any clue?
推荐答案
请看这个链接: Juergen Hoeller解释得很清楚
See this link: PROPAGATION_NESTED versus PROPAGATION_REQUIRES_NEW? Juergen Hoeller explain it very well
另一方面,PROPAGATION_NESTED启动嵌套事务,
这是现有事务的真正子事务。将发生什么
是在嵌套的
事务开始时将采取保存点。如果嵌套事务失败,我们将回滚到保证点
。嵌套事务是外部
事务的一部分,因此它只会在外部
事务的末尾提交。 ...
PROPAGATION_NESTED on the other hand starts a "nested" transaction, which is a true subtransaction of the existing one. What will happen is that a savepoint will be taken at the start of the nested transaction. Íf the nested transaction fails, we will roll back to that savepoint. The nested transaction is part of of the outer transaction, so it will only be committed at the end of of the outer transaction. ...
这篇关于Spring事务中requires_new和嵌套传播之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!