i have the following scenario:
i have a stateless ejb with two method A()
and B()
. The method B()
perform n call to method A()
which execute an INSERT operation.
Now, if A() throws an applicationException ( that i have annotated with @javax.ejb.ApplicationException(rollback=true)
) and i catch this exception in a catch block of method B(), this doesn't rollback my transaction e so the INSERT is executed:
public void A() throws ApplicationException {
.....//some logic here doInsert(); //entity layer method that perform the insert operation throw new ApplicationException(); // this is only for test
}
this is method B():
public void B() {
try{
A(); //this method is called n time in a loop but it doesn't matter
} catch (ApplicationException e){
e.printStackTrace();
}
This is the applicationException:
@javax.ejb.ApplicationException(rollback=true) public class ApplicationException extends Exception {
public ApplicationException() { super(); }
}
Obviously, this behavior does not occur if i remove the catch block in the method B(). Now, i'm wonder if there's a way to rollback my transaction even if i catch the exception in the method B(). Thankss!!!!