Help coderanch get a
new server
by contributing to the fundraiser
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

using setRollbackOnly in BMT

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it will be rolled back.
it wont commit for sure.
thats why its there setRollbackOnly() to rollback the transaction..
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hope this is clear


no
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic