This question comes from that, if I have a methodA, and methodB in classA like below
public class classA {
public void methodA() {
// some code
...
// time to deal with db
methodB();
}
@Transactional
public void methodB() {
// insert a record
throw new RuntimeException("testing");
}
}
In classB Directly call methodA, there will be no transactional effect on methodB(this is to say spring will not rollback the insert operation even RuntimeException
occurred).
When I move the @Transactional
from methodB to methodA, and call methodA again, the @Transactional
annotation works.
However, if I have really a lot of work to do in methodA
, will spring lock the table during the total execution time?