Hi guys! I´m having the following problem:
I have 2 classes (A and B). The class A has a method (method1) annotated with @Transaction(noRollBackFor = ExceptionB.class)
that calls the method2 from class B. ExceptionB is a non-checked RunTimeException.
public class A {
...
@Resource
private B b;
@Transaction(noRollBackFor = ExceptionB.class)
public void method1() {
try {
b.method2();
} catch (ExceptionB e) {
// Change objects annotated with @Entity (must be persisted)
throw e;
}
}
}
@Transaction
public class B {
...
public void method2() {
...
throw new ExceptionB();
}
}
However, when the class B throws the exception, a Spring Interceptor gets the exception and uses the class B transaction annotation rules (that don´t have the noRollBackFor rule) and do the transaction rollback. In this way, all the changes done in method1 aren´t persisted. What should I change to the rollback doesn´t happen?
Thank you in advance.