Re: Container-managed Transactions scope
- From: "John C. Bollinger" <jobollin@xxxxxxxxxxx>
- Date: Thu, 19 May 2005 08:46:21 -0500
Rizwan wrote:
I work on stateless session EJBs which are using Container-managed Transactions. My Inserts, Updates and Deletes are inside an EJB method. I never call any commit/rollback.
Now i am starting to use DAO pattern. So Inserts, Updates and Deletes are available as DAO methods. Now the EJB calls the DAO methods to do this kind of stuff. The DAOs are not doing any commit/rollback. My question is will the Container-managed Transactions be extended to the DAOs automatically.
For example I have 3 updates as part of one transaction. These 3 updates are available in 3 different DAOs. If any one of them fail I want to rollback the whole transaction. Before when these 3 updates are inside EJB, I was safe because of Container-managed Transactions. But now they are outside of EJB and I dont know if this functionality will be available.
If container do keep track of transactions like that then how many nested levels I can go on? In one particular scenario, my EJB calls a method in a class which in turn calls DAOs for Inserts/Updates/Deletes. Will they be part of Container-managed Transactions as well?
It depends on the type of DB Connection you are using. If you have configured your DataSource to provide you with XA-based Connections, or if it does so automatically, then you should be fine. If not, then you are not fine, and probably never have been. In particular, if you have been using non-XA-based Connections with autocommit enabled then your DB transactions have always been finer-grained than your J2EE transactions, and you probably could not have correctly rolled back a J2EE transaction even if you had wanted to do. (Though you might not have received any exception.) You have a better chance of using non-XA Connections correctly with bean-managed transactions, but even there you would want to make sure that auto-commit was disabled, so that you could manually ensure that JDBC transaction boundaries lined up with J2EE boundaries, and that commit / rollback corresponded.
-- John Bollinger jobollin@xxxxxxxxxxx .
- Follow-Ups:
- Re: Container-managed Transactions scope
- From: Rizwan
- Re: Container-managed Transactions scope
- References:
- Container-managed Transactions scope
- From: Rizwan
- Container-managed Transactions scope
- Prev by Date: Re: Do we have educational IDEs?
- Next by Date: Re: servlet enquiry
- Previous by thread: Re: Container-managed Transactions scope
- Next by thread: Re: Container-managed Transactions scope
- Index(es):
Relevant Pages
|