Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using setRollbackOnly in BMT

 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a bean using BMT Demarcation , if we
set userTransaction.setRollbackOnly()
and if we use userTransaction.commit() at a later point in the code , will the transaction be committed or rolled back

Could anyone throw some ideas on this?

Thanks
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it will be rolled back.
it wont commit for sure.
thats why its there setRollbackOnly() to rollback the transaction..
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you get a RollbackException by doing so ?
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you will get RollbackException only on the following cases:

bean throws system exception
calling rollback() on a BMT bean.

calling setRollbackOnly does not throw exception.
its like telling i dont want to commit this transaction.thats it.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
calling setRollbackOnly does not throw exception.its like telling i dont want to commit this transaction.thats it.

thats correct. but wouldn't you get an transactionrolledbackexception when you try to commit a transaction that has been marked as "setrollbackonly"?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Lynette pointed out, I wanted to know if you'd get one when calling commit()
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no never.
in 376 page of spec says:
If the instance called setRollback-Only(), then rollback the transaction, and re-throw AppException. Otherwise, attempt to commit the transaction, and then re-throw AppException.

also a main thing from documentation is :for transaction rolled back exception
This exception indicates that the transaction associated with processing of the request has been rolled back, or marked to roll back.

so in BMT you start a new transaction.the clients transaction is suspended forever..so in BMT calling setRollbackOnly() rollbacks the BMT bean transaction not the request(clients)..so the exception will not be thrown when you call commit.

but for cmt in case of "required" and "mandatory" if clients transactions there and you call setR.. then exception will be thrown.
hope this is clear
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hope this is clear

no
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
transaction exceptions are thrown only when the client transaction is marked for rollback or rollbacked.

for BMT...the bean starts a new transaction.so the client transaction is suspended.so it(client) wont get exceptions.
is this clear?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic