I have a strange problem. In a servlet, I am starting a Transaction
UserTransaction ut = mySessionCtx.getUserTransaction();
and trying to update two tables thru two Entity Beans .
If both go through successfully i am committing the changes
else I want to roll back. My problem is the first update changes are getting commitied even if the second update is failing . When the second update fails it is giving me a message saying Tansaction Rolled Back but still the first update changes are not being rolled back. The transaction attributes of the session bean are TX_BeanManaged and for Entity beans TX_Supports Any Help please !!!
Can you try the following steps to troubleshoot your problem ?
1. Obtain a connection from the dataSource (data source to which entity beans are mapped.)
2. On the connection object call getAutoCommit() and check its value. The value, IMO, shouldnt be true.
I was slightly wrong in the way I phrased the problem. I am dealing with Enterprise Session (Stateless) Beans not Entity beans (my fault sorry!). The Stateless Session beans use db helper classes instead of Entity beans to do inserts. So I am not sure if you suggestion will work. Any other ideas.
I am also facing the same problem. I am using Weblogic5.1 .My code looks like the following.
ut = (javax.transaction.UserTransaction)initial.lookup("javax.transaction.UserTransaction");
calling db method 1 on another bean
calling db method 2 on another bean
When autocommit is true:
When the method 2 fails method 1 still commits the changes in the database.
When autocommit is false:
When both the method passes still none of them commits the changes in the database.
If you got any solution to your problem please respond me.