-
1. Re: Transaction handling for application level exception
adrian.brock Jan 23, 2003 8:34 AM (in response to srshende)try
{
...
}
catch (Exception e)
{
context.setRollbackOnly();
throw e;
}
Regards,
Adrian -
2. Re: Transaction handling for application level exception
srshende Jan 23, 2003 10:50 PM (in response to srshende)Hello Adrian,
Thanks for the reply. But I did not get where to write the bolck of code you mentioned. I have a session bean which calls helper java class and my java class throws exception. So the code you mentioned should be written in session bean while calling that helper class or in the helper class which throws exception. Please elaborate. Awaiting your reply.
Regds,
Sanjay -
3. Re: Transaction handling for application level exception
allank Mar 10, 2003 4:39 AM (in response to srshende)Hi Adrian,
We are also having almost the same problem as Sanjay and we implemented your solution.
We initialized the UserTransaction as
UserTransaction userTxn = null;
try {
userTxn = (UserTransaction)ctx.lookup("UserTransaction");
userTxn.begin();
....
//some SQL statements
....
userTxn.commit();
}catch (Exception e){
userTxn.rollback();
}
The problem with the above implementation is, it throws a transaction nested exception.
We have another implementation without the begin and commit(?)..
UserTransaction userTxn = null;
try {
userTxn = (UserTransaction)ctx.lookup("UserTransaction");
....
//some SQL statements
....
}catch (Exception e){
userTxn.setRollbackonly();
}
The above implementation on the otherhand, does not rollback!
Do you have any idea what is wrong?
Thanx in advance.