Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HFE 556 POINT:5

 
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
 
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.
 
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.
 
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic