Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

rollback() and setRollbackOnly()

 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • 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
 
Marco Barenkamp
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
If you're gonna buy things, buy this thing and I get a fat kickback:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!