I am using container-managed transaction in my EJB application.
I have two stateless Java objects, which are class A and class B.
class B is instantiated in a method of class A.
Class B has two methods : method A and method B.
Method A is using transaction type = requires_new
Method B is using transaction type = required
There are 2 sql insertion statement in the two methods respectively. Method A and method B have different sql statement.
I find out that if there is any error happened in method B, everything in method A is rollback. This is not I want. I want everything in method A is committed even though method B raise System exception.
Thus, I don't think method A and B are running using a different transaction.
Can I know is there any way to system.out.println a boolean value showing a JTA transaction is new or not?
Thanks.
Below is the additional pseudo-code snippet to clarify my question above.
stateless class A{
method(){
Class b = new Class B();
b.methodA();
b.methodB():
}
}
stateless class B(){
method A(){ // There is an insert statement here.}
method B(){ // There is another insert statement here.}
//If anything happen in method B, only rollback B, don't rollback A.
}