So I was trying to create nested transactions but it's not working at all..
@Transactional
method1(){
method3();
method4();
}
method4(){
try{
method2();
}catch(Exception e){
log.error("exception found, i will retry method2() by calling method4()");
method4();
}
}
@Transactional
method2(){
//do something
}
@Transactional
method3(){
//do something
}
So my requirement is like this, method 1's transactional should work as expected, let's say method4() was successful, and its committed. Now let's say there happened to be some exception on method3(), now I was expecting method4(internally method 2)'s commit to be reverted as it's a part of method1()'s transaction.. But what I see is, even with method3's failure/exception, commit of method2 is not rolling back. Shouldn't it ideally roll back as it's a part of method1's transaction?
M i doing something wrong here?