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

HFE 556 POINT:5

 
pradeep arum
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A bean realises it cant commit a transaction ,but it does'nt want the client to get an exception.what can the bean do?
what does the question mean?
I think....there is a TransactionRolledBackException() if the caller is also is in the same context...so use a try/catch to catch the exception and not let the exception propagate to the container ..and then to the client.am I correct?
please throw some light
thanks
Pradeep
 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A bean realises it cant commit a transaction ,but it does'nt want the client to get an exception.what can the bean do?

You can simply invoke setRollbackOnly() on EJBContext .
Transaction is rolledback in two ways:
- bean throws system exception - very bad way (the bean is dead)
- invoke setRollnackOnly() on EJBContext for CMT || invoke getUserTransaction().setRollbackOnly() for BMT.
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TransactionRolledbackException is itself a system exception and thus should never be caught in your bean.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic