Is it possible to nest @Transactional annotated methods in spring? 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
@Transactionalannotation on methodb()is not required because by default@Transactionalhas a propagation ofREQUIRED, therefore methods called by methoda()will be transactional. If you are looking to start a new transaction within a method called by methoda()you will need to modify the propagation rules. Read about Transaction Propagation.