• 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

setRollBackOnly Doubt

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am preparing for my SCBCD exam using the HFEJB book. It seems to be an excellent book. well my doubt is, setRollBackOnly is something like a flag to notify the other concurrent methods taking part in transaction that something bad is going to happen. So that those methods can first check this flag and decide whether to proceed or not. My question is , why do we want to proceed with the next concurrent method in transaction if we set the "setRollbackOnly" flag. Why don't we just rollback right from there ??
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Giju,
I think you already know that getRollbackOnly() and setRollbackOnly() methods are used by beans with container managed transactions. In CMT, you have no way to rollback a transaction because there is no rollback() method available to do that. Remember rollback method is only available to the BMT beans. If you do not want to proceed with the next method in transaction, you can throw application exceptions, but again throwing application exceptions do not automatically cause the transaction to roll back. So you have to mark the transaction for rollback by calling setRollbackOnly() before throwing the exception.

Hope this helps
Suman
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just would like to add one more note...

setRollbackOnly is mainly useful when the application exceptions are thrown, It gives a chance to the client to recover from the exceptions.
 
We noticed he had no friends. So we gave him this tiny ad:
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