- In EJB 3 in Action section 6.2.5 Transaction and exception handling.
- In Entreprise JavaBeans 3.0 (O´Relly) Section 16.6 Exceptions and Transactions.
SCJP 6.0, SCBCD 5.0, SCDJWS 5.0
Joined: Nov 19, 2008
I read this tutorials but still I'm fail
I'm using container manager transaction and persist account details. if some body try to persist incorrect account information I want to give customer exception(message) instead of system generated message. Above code show that but this not work. please help me how to it?
With CMT, the actual queries are fired on transaction completion, i.e. after the method exits. So the catch block will never be able to catch such exceptions which happen within a transaction synchronization callback. You'll see the difference if you add a em.flush after the em.persist. That way, the queries will be fired immediately instead of waiting for tx synchronization: