I am using client demarcation and calling two methods on a stateless session bean for example (withdraw & deposit). It doesn't work. There is no impact of the rollback done at the client. Can any one shower some light in this regard
Thanks
venkatesh
-
Transactions (7 messages)
- Posted by: venkatesh gnanasekaran
- Posted on: December 29 2001 00:30 EST
Threaded Messages (7)
- Transactions by Gagan Bhalla on December 29 2001 15:33 EST
- Transactions by venkatesh gnanasekaran on December 31 2001 03:03 EST
-
Transactions by Suresh Rangan on December 31 2001 11:05 EST
-
Transactions by Benedict Chng on January 02 2002 05:12 EST
- Transactions by Suresh Rangan on January 02 2002 10:35 EST
-
Transactions by Adnan Rafiq on January 02 2002 01:12 EST
- Transactions by Suresh Rangan on January 02 2002 02:38 EST
-
Transactions by Benedict Chng on January 02 2002 05:12 EST
-
Transactions by Suresh Rangan on December 31 2001 11:05 EST
- Transactions by venkatesh gnanasekaran on December 31 2001 03:03 EST
-
Transactions[ Go to top ]
- Posted by: Gagan Bhalla
- Posted on: December 29 2001 15:33 EST
- in response to venkatesh gnanasekaran
What are the transactional attributes that you have set on the bean(s)? I assume that your SLSB's are a facade to the CMP/BMP entity beans actually making the transactions at the database level?
GJB
PS: For a good discussion on this/similar issues with transactional attributes, take a look at Chapter 10 & 14 from Ed Roman's book Mastering EJB1, available from this site.
-
Transactions[ Go to top ]
- Posted by: venkatesh gnanasekaran
- Posted on: December 31 2001 03:03 EST
- in response to Gagan Bhalla
I am not using any entity beans. My session bean methods just uses tx datasource to get a connection and does the database operations. I have used TX_BEAN_MANAGED. For examples
Client
step 1 . getUserTransaction through lookup
step 2 . ut.begin();
step 3 . Bean.withdraw();
step 4 . Bean.deposit();
step 5 . ut.commit();
step 6 . Any Exception ut.rollback();
-
Transactions[ Go to top ]
- Posted by: Suresh Rangan
- Posted on: December 31 2001 11:05 EST
- in response to venkatesh gnanasekaran
There is difference between a transactions at bean level and transactions at database level.
Whatever database transaction you have made is already commited. so the user or the container will not be able to make the rollback by itself.
Instead you can create a connection with autocommit set to false. Use the same connection object as reference to do all your transactions. Finally if all the transaction goes fine then before doing the ut.commit in your code, do the database commit.
incase of ut.rollback do the connection.rollback.
this will take care of your rollback operations in database level.
All the best -
Transactions[ Go to top ]
- Posted by: Benedict Chng
- Posted on: January 02 2002 05:12 EST
- in response to Suresh Rangan
Make sure you're using a Transaction Datasource and set your autocommit to false. Contrary to what Suresh Rangan has claimed, I believe you do not need to pass your Connection reference objects around. Under the "umbrella" of a transaction demarcated by your client, your single bean/multiple beans access will use the same Connection reference automatically until your client commits/rolls back. -
Transactions[ Go to top ]
- Posted by: Suresh Rangan
- Posted on: January 02 2002 10:35 EST
- in response to Benedict Chng
Hi Chng, i think u got me wrong. what i was trying to say was when different object doing different database updates and if the business needs everything under a single umbrella then its very essential that all the object should use the same database connection objects.
Especially when we are using Weblogic or any connection pool. we need to keep the resource till we are done with that particular transaction.
i had the same problem and i solved it this way and now it works fine.
Regards
Suresh -
Transactions[ Go to top ]
- Posted by: Adnan Rafiq
- Posted on: January 02 2002 13:12 EST
- in response to Suresh Rangan
<SURESH> Finally if all the transaction goes fine then before doing the ut.commit in your code, do the database commit.
incase of ut.rollback do the connection.rollback.
this will take care of your rollback operations in database level.
</SURESH>
I am still not convinced that you have to issue database commit or rollback explicitly. I thought the whole point was to let the EJB container manage transacations on your behalf. As long as all the objects (EJBs) involved are using the same connection pool, you don't have to worry about explicitly managing trasactions at the database level.
-
Transactions[ Go to top ]
- Posted by: Suresh Rangan
- Posted on: January 02 2002 14:38 EST
- in response to Adnan Rafiq
Thats true Rafiq, but only when you are using Container Managed Persistence. when u use transactions from SessionBean-JDBC level or BMP level we need to explicitly take care of the database transaction.