您好。以下是代码:
class A{
private B b;
@Transactional
public SomeResult doSomething(){
SomeResult res = null;
try {
// do something
} catch (Exception e) {
res = b.saveResult();
}
return res ;
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
class B{
public SomeResult saveResult(){
// save in db
}
}
据我理解,如果在方法doSomething
中出现异常,事务不会回滚。如何使其回滚并返回SomeResult呢?