File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes ejb container-managed transaction, nested calls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb container-managed transaction, nested calls" Watch "ejb container-managed transaction, nested calls" New topic
Author

ejb container-managed transaction, nested calls

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
------------------
Lets say

A client calls a ejb myEjb1's business method AA()

and AA calls ejb myEjb2's business method BB()

and both are container-managed 'Required' transactions, when BB finishes, is the whole transaction committed including previous AA updates? or the whole transaction only updates once at the end of AA method?
------------------
Also, how about if both 'RequiresNew'?
------------------
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

First case the AA method surrounds BB method, so AA method is the one that created the transaction and will be the one to commit it when it completes, if a commit happens.

In your second example. AA's transaction suspends as a new transaction is created for BB, when BB finishes BB's transaction commits, then AA transaction unsuspends and when AA finishes it commits the transaction.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Originally posted by Mark Spritzler:
First case the AA method surrounds BB method, so AA method is the one that created the transaction and will be the one to commit it when it completes, if a commit happens.

In your second example. AA's transaction suspends as a new transaction is created for BB, when BB finishes BB's transaction commits, then AA transaction unsuspends and when AA finishes it commits the transaction.

Mark


In the second example, even if BB commits, if AA rollback after calling BB, both AA and BB are rolled back right? (I am thinking about both method possibly accessing same resource, even same table row, so BB is on top of AA, and BB essentially fails if AA fails.)
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

No. BB will not be rolled back once it commits. Transaction AA is not wrapping around Transaction BB, it is suspending while Transaction BB starts and end. The resume where it left off. If you want the wrapping, then BB should be either Supports or Requires. But with Supports if AA does not have a transaction, then neither will BB.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejb container-managed transaction, nested calls