dcsimg
How to manage the database transaction in case of stateless session beans ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeevan_Sunkersett
Posted On:   Thursday, June 21, 2001 05:11 AM

Hi, I guess everybody is aware on the behaviour of Entity Beans (EB) in a transcation scope. eg. If my one Stateless session bean (SLB), starts a user transaction, (getUserTransaction().begin() of the session context object). Subsequently invokes an EB to insert data into a database table. On return from the EB, the SLB rollsback the transaction (getUserTransaction().rollback() of the session context object) The EJB container at this point automatically handles the rollback of the EB as well - ie. the data inserted into the database, prior to the transaction rollback, is ALSO rolled back. Well this can be attributed to the features of the container. My problem begins here. From my current projec   More>>

Hi,



I guess everybody is aware on the behaviour of Entity Beans (EB) in a transcation scope.


eg. If my one Stateless session bean (SLB), starts a user transaction, (getUserTransaction().begin() of the session context object). Subsequently invokes an EB to insert data into a database table.
On return from the EB, the SLB rollsback the transaction (getUserTransaction().rollback() of the session context object)



The EJB container at this point automatically handles the rollback of the EB as well - ie. the data inserted into the database, prior to the transaction rollback, is ALSO rolled back.



Well this can be attributed to the features of the container.



My problem begins here. From my current project we are to replace all Entity Beans by stateless session beans (SLB's). The database logic of EB's will be handled in the SLB by using JDBC.
The problem therefore is if a SLB, calling this EB-converted-to-SLB, were to rollback the user transcation after the insert of data to the database. how can the container be instructed to also rollback the database insert done in the EB-converted-to-SLB.



The EB-converted-to-SLB acquires its own database connection from the pool. Keeps the AutoCommit flag at its default (ie True). Inserts the data (via JDBC). Disconnects/ closes the database connection and returns control to the calling SLB.



Any clues in this scenario ?



Detailed clues would be appreciated.



rgds
Jeevan S

   <<Less

Re: How to manage the database transaction in case of stateless session beans ?

Posted By:   Ravi_Potluri  
Posted On:   Wednesday, October 24, 2001 12:03 PM

You don't have to do anything special other than marking the methods doing the database updates with appropriate transaction attributes(Supports, Required or Mandatory). There are other restrictions that you probably know already. ie. You should not call commit method on java.sql.Connection.
About | Sitemap | Contact