Transaction in Stateless Session Bean using SQL
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ashok_ayengar
Posted On:   Wednesday, July 17, 2002 04:14 AM

I have a Stateless session bean which has 3 methods. 1. x() 2. deleteRecord() 3. insertRecord(). the scenario is i want to delete and insert records to a particular table and i want it to be under one transaction. deleteRecord() and insertRecord() methods are private methods. each method gets the Connection from the Weblogic connection pool using the datasource. I'm calling there 2 methods successively in the x() method. How do i handle the transaction for this situation. I have tried this but the transaction is not working... i.e. it deletes the records from the table but does not insert it and in insert method i'm trying to insert a value which is null( only for testing).    More>>

I have a Stateless session bean which has 3 methods.
1. x() 2. deleteRecord() 3. insertRecord().

the scenario is i want to delete and insert records to a particular table and i want it to be under one transaction.

deleteRecord() and insertRecord() methods are private methods.

each method gets the Connection from the Weblogic connection pool using the datasource.

I'm calling there 2 methods successively in the x() method.
How do i handle the transaction for this situation.

I have tried this but the transaction is not working...
i.e. it deletes the records from the table but does not insert it and in insert method i'm trying to insert a value which is null( only for testing).

Actual result should be when it throws an exception it should not delete the records from the table i.e. it should rollback the transaction.

can you please help in this regard..
if i use the Entity Bean in this case it works...but i don't want to use the Entity Beans..


regards,
ashok

   <<Less

Re: Transaction in Stateless Session Bean using SQL

Posted By:   Gautam_Marwaha  
Posted On:   Wednesday, July 17, 2002 04:21 AM

make sure x() is a transactional method in the deployment descriptor. Further, insertRecord and deleteRecord methods shd throw SQLException for x() to catch. In the catch block of SQLException in x(), mark the txn for rollback (using sessionContext.rollbackOnly() method)
About | Sitemap | Contact