This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejb container-managed transaction, nested calls

 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
------------------
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic