-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Exception handling in EJB with CMT Using Hibernate
PostPosted: Wed Feb 06, 2008 1:42 am 
Newbie

Joined: Wed Feb 06, 2008 1:23 am
Posts: 3
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 10:04 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
call flush() explicitely

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.