Hi
We are having a situation where we a calling a stateless session bean (B1) method, say method A from another stateless session bean(B2) method, say B.
A database insert operation in method A is resulting in a exception. In method B we are catching the exception and calling m_objSessionContext.setRollbackOnly() on the SessionContext object.But the record inserted in the database is not rolledback. Please help me understand the problem and guide me with the solution.
Note: The transaction attributes for both the beans B1 and B2 is "Required" with a trasaction isolation level of "READ-COMMITED"
Thanks in advance
Awaiting a reply
Deepa
-
Transcation rollback from a bean (4 messages)
- Posted by: Deepa Nadig
- Posted on: July 25 2002 08:15 EDT
Threaded Messages (4)
- Transcation rollback from a bean by Bhagvan Kommadi on July 25 2002 08:54 EDT
- Transcation rollback from a bean by Deepa Nadig on July 26 2002 08:54 EDT
- Transcation rollback from a bean by jawad hussain on July 25 2002 09:10 EDT
- Transcation rollback from a bean by Joe Mallings on July 26 2002 04:40 EDT
-
Transcation rollback from a bean[ Go to top ]
- Posted by: Bhagvan Kommadi
- Posted on: July 25 2002 08:54 EDT
- in response to Deepa Nadig
As you are using a stateless session bean, the transactional context of bean 1 method1 won't be
accessible to bean2 method2.
ejb spec says:
A stateless session bean instance must commit a transaction before a business method returns. -
Transcation rollback from a bean[ Go to top ]
- Posted by: Deepa Nadig
- Posted on: July 26 2002 08:54 EDT
- in response to Bhagvan Kommadi
In the bean B1, the method does a explicit setRollBackOnly in case of exception. Will this not rollback the transaction in bean B2?
Is there any other alternate to this problem. -
Transcation rollback from a bean[ Go to top ]
- Posted by: jawad hussain
- Posted on: July 25 2002 09:10 EDT
- in response to Deepa Nadig
Hi,
There is no conversional state maintained between methods when u are using Stateless Session Beans.
Stateless SB's are only used for a instance of method invocation, use a single method to do the task of insertion. Then even u can implement transaction in it.
Thanx & Reagrds
Jawad
jawad at vsnl dot com
-
Transcation rollback from a bean[ Go to top ]
- Posted by: Joe Mallings
- Posted on: July 26 2002 04:40 EDT
- in response to jawad hussain
Actually you can rollback from stateless session beans you just need to make sure that you have disabled AUTO COMMIT on your database or ensure you have set up a TX DataSource. I assume since you are using context.setRollbackOnly that you have correctly specified Container under <transaction-type> in your ejb-jar.xml file.