• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Important Query about nested transaction in EJB

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am an aspirant for the SCEA part I. I have a couple of questions:
1. The Book Ed Roman states that the EJB does not mandates the support for the nested transaction by the container. But If the requiresNew attribute is used the opeartions as per the book which i am copy pasting here is simillar to the nested transaction. The extract from the book is

RequiresNew
You should use the RequiresNew attribute if you always want a new transaction
to begin when your bean is called. If a transaction is already underway when
your bean is called, that transaction is suspended during the bean invocation.
The container then launches a new transaction and delegates the call to the
bean. The bean performs its operations and eventually completes. The container
then commits or aborts the transaction and finally resumes the old transaction. Of course, if no transaction is running when your bean is called, there is nothing to suspend or resume.RequiresNew attribute if you always want a new transaction to begin when your bean is called. If a transaction is already underway when your bean is called, that transaction is suspended during the bean invocation. The container then launches a new transaction and delegates the call to the bean. The bean performs its operations and eventually completes. The container then commits or aborts the transaction and finally resumes the old transaction. Of course, if no transaction is running when your bean is called, there is nothing to suspend or resume. RequiresNew is useful if your bean needs the ACID properties of transactions but wants to run as a single unit of work without allowing other external logic to also run in the transaction.is useful if your bean needs the ACID properties of transactions but
wants to run as a single unit of work without allowing other external logic to also run in the transaction.
Is it not what we call a nested transaction???

2. What hapens to the locks in the above case which are acquired by the parent transaction during the time of there suspensition. Are the lock released or they remain acquired?

Please answer my above queries. Thanks in Advance.
 
Anna
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So Nobody here to answer my query. It was not answered at any other places also. Please help me out
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Nested Transaction has 3 properties
i. One root transaction and several branched transactions.
ii. One branched transaction rolled back does not cause the entire transaction to roll back.
iii.The root transaction is rolled back, and this will roll back all the branched transactions.

Now, look at the RequireNew
i. One root transaction and several branched transactions.
Well, RequireNew forces the current transaction to pause, and starts another transaction. This is really two transaction.
ii. One branched transaction rolled back does not cause the entire transaction to roll back.
Well, yes, because it is two transactions, you roll back one transaction, of course it does not affect the other transaction.
iii.The root transaction is rolled back, and this will roll back all the branched transactions.
Well, suppose you use required new, and the first transaction is paused, and starts the second transaction. Second transaction completes, and the first transaction resume, and you decide to roll back the first transaction. This will not roll back the second transaction because it already commits.

As a result, RequireNew is not nested transaction because only 1 property SEEMS to fit. You need all 3.

2) When you use RequireNew, the first transaction is paused, and the lock is not released.

[ September 09, 2005: Message edited by: Jeremy Hsu ]
[ September 09, 2005: Message edited by: Jeremy Hsu ]
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anna,

Nested transactions provide options to select other paths if a nested transaction rollbacks, sample: a travel agency which try to build an itinerary for a customer. You may emulate, just emulate, nested transactions with SavePoint introduced in JDBC 3.0

Regards

Akar
 
Anna
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot for the response.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic