• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

rollback() and setRollbackOnly()

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
There are two methods to roll back a transaction in the javax.transaction.UserTransaction interface.
It seems to me that both rollback() and setRollbackOnly() will roll back the transaction. What is the difference between them, and when shold I use rollback() and when setRollbackOnly()?


------------------
Thanks,
Mike
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
if you use the UserTransaction (Bean Managed Transaction, not possible with Entitiy Beans), you can roolback this transaction
using rollback().
If you use Container Managed Transaction ( Session and Entity)
you have to mark the Transaction as to be rollbacked using
setRollbackOnly() in order to rollback this transaction.
------------------
Marco Barenkamp
____________________________________________
L M I N T E R N E T S E R V I C E S AG
Senior Trainer & Architect,
BEA Certified Enterprise Developer
Sun Certified Programmer for the Java2 Platform
Sun Certified Web Component Developer for the Java2 Platform
Sun Certified Developer for the Java 2 Platform
Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition (PI)
 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marco,
Your reply is really usefull. However, I have a further question about this issue:
In a Container-Managed transaction, we have to call setRollbackOnly() method on an object of EJBContext interface. The setRollbackOnly() of the UserTransaction interface is not allowed in a Container-Managed transaction. Then, what is The setRollbackOnly() of the UserTransaction interface uesed for?

------------------
Thanks,
Mike
 
reply
    Bookmark Topic Watch Topic
  • New Topic