Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
saran ram
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?
 
Bart Laeremans
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?
 
Thiru Thangavelu
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic