Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Clarification on Trsxn propagation frm BMT to CMT

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a doubt, say I start a trsxn (tc1) in a BMT its not committed, i call a method of another bean with CMT with a trsxn (tb2), if I call setRollBackOnly() over in this method, while this method returns to my bmt method which is in trsxn tc1 and try to do a getStatus() will my trsxn be rolled back.
Ogi.. let me summarize, Can I rollback a BMT trsxn from CMT trsxn?

-Stephen
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I you start a transaction in a BMT bean, you can call a CMT bean which will participate in the same transaction. If the CMT bean calls setRollbackOnly() the transaction will be rolled back.

1. Bean1 start a transaction (tx.begin)
2. Bean1 calls method on bean2 which has tx attrib required (so its CMT)
3. The method on bean2 calls setRollbackOnly
4. The method in bean1 will get a TransactionRolledBack(Local)Exception

Note that there is NO tx2. If the trans attrib on bean2 was requiresNew, a tx2 would have been started by bean2 which would not affect the tx started by bean 1. Also, Bean one cannot start a second transaction when the first one is not commited.

So, a BMT started transaction can propagate to a CMT bean. A transaction started in a CMT bean can only progagate to a CMT bean and NOT a BMT bean.
 
Stephen Selvaraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
many thanks Koen,
-Stephen
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic