• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Nested transaction in EJB

 
NareshAnkuskani Kumar
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across a statement that there are no nested transactions as of EJB2.0. Please have a glance at the example stated below

e.g.
Consider two CMT Beans A & B.
Bean-A contains a method foo() with a transaction attribute "Required".
Bean-B contains a method boo() with a transaction attribute "RequiresNew".

Now when a method "foo()" in a transaction calls method "boo()", the incoming transaction from "foo()" is suspended temporarily and the method "boo()" starts a new transaction.

My Question:Is not the above is an example of nested transactions (or) my interpretation itself is wrong.
 
Rajesh Tongia
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well yes your interpretation is completely wrong here.

Here in this case transactions T2 (Transaction started by the method boo()) is not running inside transaction T1 (Transaction for foo()). So there's no nested transaction.

Transaction T1 is suspended while transaction T2 is running. Once T2 completes , T1 resumed.

I hope this will clear some of your confusion.

Regards,

Rajesh
 
Arun Natarajan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If transaction T2 fails, T1 may still commit fine and vice-versa.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic