In page 556 of HFEJB what's the answer for Point no.6?
saran ram
Ranch Hand
Joined: Dec 13, 2002
Posts: 69
posted
0
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
Joined: Aug 06, 2001
Posts: 6
posted
0
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
Joined: Dec 13, 2002
Posts: 69
posted
0
Bart, that means,if we call setRollbackOnly() before throwing the exception, will the transaction surly gets committed?
Thiru Thangavelu
Ranch Hand
Joined: Aug 29, 2001
Posts: 219
posted
0
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.