• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

setRollBackOnly Doubt

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
That feels good. Thanks. Here's a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic