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

In page 556 of HFEJB what's the answer for Point no.6?

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In page 556, point 6,
A bean wants the client to get an application exception, but the bean still wants the transaction to commit. What should the bean do? what's the answer for this?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just studying for the exam myself, and I think the
answer is as followed.

The bean should just throw the application exception,
because only system exception would automatically cause
the transaction to rollback.

To roleback a transaction with a application exception
the bean should call setRollbackOnly before throwing
the exception.

Greetings
 
saran ram
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bart, that means,if we call setRollbackOnly() before throwing
the exception, will the transaction surly gets committed?
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, If you call setRollbackOnly() before throwing the exception, the transaction will never get committed. If you don't call the container will commit the transaction before throwing the application exception.
 
I'm doing laundry! Look how clean this tiny ad is:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic