File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed
docs/system-design/framework/spring Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -389,14 +389,13 @@ Class B {
389389
390390** 3.` TransactionDefinition.PROPAGATION_NESTED ` ** :
391391
392- 如果当前存在事务,则创建一个事务作为当前事务的嵌套事务来运行;如果当前没有事务,则该取值等价于` TransactionDefinition.PROPAGATION_REQUIRED ` 。也就是说:
393-
394- 1 . 在外部方法未开启事务的情况下` Propagation.NESTED ` 和` Propagation.REQUIRED ` 作用相同,修饰的内部方法都会新开启自己的事务,且开启的事务相互独立,互不干扰。
395- 2 . 如果外部方法开启事务的话,` Propagation.NESTED ` 修饰的内部方法属于外部事务的子事务,外部主事务回滚的话,子事务也会回滚,而内部子事务可以单独回滚而不影响外部主事务和其他子事务。
392+ 如果当前存在事务,就在嵌套事务内执行;如果当前没有事务,就执行与` TransactionDefinition.PROPAGATION_REQUIRED ` 类似的操作。也就是说:
396393
394+ 1 . 在外部方法开启事务的情况下,在内部开启一个新的事务,作为嵌套事务存在。
395+ 2 . 如果外部方法无事务,则单独开启一个事务与 PROPAGATION_REQUIRED 类似
397396这里还是简单举个例子:
398397
399- 如果 ` aMethod ()` 回滚的话,` bMethod() ` 和 ` bMethod2() ` 都要回滚,而 ` bMethod() ` 回滚的话,并不会造成 ` aMethod() ` 和 ` bMethod()2 ` 回滚。
398+ 如果 ` bMethod ()` 回滚的话,` aMethod() ` 回滚。
400399
401400``` java
402401Class A {
@@ -405,7 +404,6 @@ Class A {
405404 // do something
406405 B b = new B ();
407406 b. bMethod();
408- b. bMethod2();
409407 }
410408}
411409
@@ -414,10 +412,6 @@ Class B {
414412 public void bMethod {
415413 // do something
416414 }
417- @Transactional (propagation = propagation. PROPAGATION_NESTED )
418- public void bMethod2 {
419- // do something
420- }
421415}
422416```
423417
You can’t perform that action at this time.
0 commit comments