Reputation: 13426
Lets say I have the following 2 classes.
class A {
private B b;
@Transactional
public void a(){
b.b();
//do a stuff
throw new RuntimeException("oops");
}
}
class B {
@Transactional
public void b(){
//do b stuff
}
}
In this case will the method b()
(or b stuff) be rolled back as well?
Upvotes: 0
Views: 355
Reputation: 57381
In your case it will be rolled back.
If your B b;
is autowired by Spring (in your case it seems it's not) and @Transactional
on the b()
method has propagation REQUIRES_NEW (currently it default - REQUIRE) which means don't use existing transaction but start a new so only in this case commit on b()
is not rolled back.
Upvotes: 3