Hi,
I am using EJB with transaction-type specified as "Container" in ejb-jar.xml. I am also using Hibernate for DB operations. Code in my DAO lokks something like the following.
EntityManger entityManager = getEntityManager(); // this line will get the appropriate entity manager from EntityManagerFactory.
try {
enttyManager.merge(obj);
} catch (exception e) {
e.printStacktrace(); // never comes here when the exception occurs
} finally {
entityManger.close();
}
Whenever the update operation fails due to valid reasons, all the stacktraces are printed and even the transaction is rollbacked as required. But never comes in to catch block in my code. Hibernate itself is handling all the exception I hope. I would like to handle those exception in my code and I wolud like to provide appropriate customized error message to the user. How shall I handle.
Please help me.
|