Spring 事务中 requires_new 和嵌套传播的区别 [英] Differences between requires_new and nested propagation in Spring transactions

查看:23
本文介绍了Spring 事务中 requires_new 和嵌套传播的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解 PROPAGATION_REQUIRES_NEWPROPAGATION_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?

推荐答案

查看此链接:PROPAGATION_NESTED 与 PROPAGATION_REQUIRES_NEW? Juergen Hoeller 解释得很好.-- Spring Source 论坛于 2019 年 2 月 28 日完全离线,但您可以在下面的引用中阅读文章的相关部分

See this link: PROPAGATION_NESTED versus PROPAGATION_REQUIRES_NEW? Juergen Hoeller explain it very well. -- the Spring Source Forum is completely offline sice February 28, 2019, but you can read the relevant part of the article in the quote below

PROPAGATION_REQUIRES_NEW 开始一个新的、独立的内部"事务对于给定的范围.此事务将被提交或回滚完全独立于外部事务,拥有自己的隔离范围,它自己的一组锁等.外部事务将在内部的开始时暂停,并在内一完成....

PROPAGATION_REQUIRES_NEW starts a new, independent "inner" transaction for the given scope. This transaction will be committed or rolled back completely independent from the outer transaction, having its own isolation scope, its own set of locks, etc. The outer transaction will get suspended at the beginning of the inner one, and resumed once the inner one has completed. ...

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 和嵌套传播的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆