开发者

Nested @Transactional

开发者 https://www.devze.com 2023-03-18 05:39 出处:网络
Is it possible to nest @Transactional annotated methods in sp开发者_如何学Pythonring? Consider something like this:

Is it possible to nest @Transactional annotated methods in sp开发者_如何学Pythonring? Consider something like this:

@Transactional
public void a() {
    obj.b();
}

@Transactional
public void b() {
    // ... 
}

What happens in such a case if I rollback in b() and rollback in a() ?


The second @Transactional annotation on method b() is not required because by default @Transactional has a propagation of REQUIRED, therefore methods called by method a() will be transactional. If you are looking to start a new transaction within a method called by method a() you will need to modify the propagation rules. Read about Transaction Propagation.

0

精彩评论

暂无评论...
验证码 换一张
取 消