Re: Container-managed Transactions scope



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
.



Relevant Pages

  • Re: Container-managed Transactions scope
    ... Updates and Deletes are inside an EJB method. ... > the Container-managed Transactions be extended to the DAOs automatically. ... > If container do keep track of transactions like that then how many nested ...
    (comp.lang.java.programmer)
  • Container-managed Transactions scope
    ... Updates and Deletes are inside an EJB method. ... the Container-managed Transactions be extended to the DAOs automatically. ... If container do keep track of transactions like that then how many nested ...
    (comp.lang.java.programmer)
  • Re: dbFailOnError causing varible error.
    ... I really know to little about transactions, ... CurrentDB is, as I've understood it, a reference to the current DAO database ... I guess if this failure is any indication I have not DAO code anywhere. ...
    (microsoft.public.access.formscoding)
  • Re: Transactions in Access 2000
    ... DAO ones do. ... I need to use transactions to make sure data is consistent. ... like ADO as to make the db as portable between Access versions ... ADO you shouldn't have a portability problem. ...
    (comp.databases.ms-access)
  • Re: Which Object to use for Tansaction process
    ... The only way to use a single object to wrap the transactions is if you use ... DAO or ADO exclusively. ...
    (microsoft.public.access.forms)