Spring @Transactional - Can I Override rollbackFor
- by user475039
Hi all,
I am calling a service which has the following annotation:
@Transactional(rollbackFor=ExceptionA.class)
public void myMethodA(....) throws ExceptionA {
.
.
}
I am calling this method from an other method in another Spring Bean.
@Transactional(rollbackFor=ExceptionB.class)
public void mainEntryPointMethod(....) throws ExceptionB {
.
try {
myMethodA()
}
catch (ExceptionA exp) {
.
}
.
}
My problem is that if myMethodA throws an exception, my transaction (which is passed from mainEntryPointMethod - myMethodA by default propagation) will be marked for rollback. Is there a way in which the 'rollbackFor' for the inner method can be overriden?
Thanks in advance
Chris