This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Difference between rollback() & setRollbackOnly() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Difference between rollback() & setRollbackOnly()" Watch "Difference between rollback() & setRollbackOnly()" New topic

Difference between rollback() & setRollbackOnly()

Malan Subramanian

Joined: Jul 09, 2005
Posts: 13
Hi Ranchers,
Is there any difference between the following methods in javax.transation.UserTransaction


Thanks in advance,
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

setRollbackOnly() - can be called for CMT(container managed transaction)& BMT (Bean managed transaction) beans

rollback() - can be called only for BMT beans.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
In CMT javax.Transaction.UserTransaction interface methods do not play any role.In CMT EJBContext.setRollbackOnly() plays the same role.

Both the said methods setRollbackOnly and rollback() of UserTransaction is for BMT beans.

One is used to rollback straightaway.(rollback())
Another one is to mark the transaction as doomed.Even if it is doomed the transaction will continue to the end.But will be rolledback.(setRollBack()).

With Regards,<br /> Rajan<br />"Java Rocks"
I agree. Here's the link:
subject: Difference between rollback() & setRollbackOnly()
It's not a secret anymore!