• Post Reply Bookmark Topic Watch Topic
  • New Topic

Forcing a transaction to rollback  RSS feed

 
Nesan Krish
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a method in SessionContext interface: setRollBackOnly(Boolean b). Please anyone tell me what is the usage of this method? What is realy ment by "Forcing a transaction to rollback"? Thank you very much.
[ March 10, 2004: Message edited by: Nesan Krish ]
[ March 10, 2004: Message edited by: Nesan Krish ]
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the bean has container managed transaction (CMT) demarcation, then the bean methods' transactions are managed by the container. you have to define the desired tx attribute in the deployment descriptor of the bean.
- Now if the container is managing tx for the bean, what if something goes wrong in the bean and if the bean does not want the container to commit the tx? in such a case, bean can use context.setRollBackOnly() method to indicate that the tx should /would not be commited. This is how the bean forces the tx to roll back
-Suppose a bean method m1 calls another method m2 on second bean having tx atribute Required, then the m1's tx xontext is passed to m2. suppos m2 wants to check if the tx has already bean set to roll back by m1, then it can use use context.getRollBackOnly()
Hope this makes clear.
[ March 10, 2004: Message edited by: Rashmi Tambe ]
 
Nesan Krish
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Rashmi! Your reply is very useful. Thank you very much.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!