aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate JPA persist() not throwing EntityExistsException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Hibernate JPA persist() not throwing EntityExistsException" Watch "Hibernate JPA persist() not throwing EntityExistsException" New topic
Author

Hibernate JPA persist() not throwing EntityExistsException

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hi,
I have an EJB project where I am using a SessionBean (stateless) to persist an item, the problem I am having is, when an item is added with the same primary key value, the method is supposed to throw a EntityExistException, but it is not throwing any exception, instead the caller is thrown a EJBException, I am calling this Session Bean from a different Web project. I tried adding try/catch block in the EJB to check what exception is thrown. The catch bloack doesn't get executed even when catching the generic Exception object. I am using container managed persistence? Could you please help me out with this please. Regards
[ May 17, 2008: Message edited by: Ransika deSilva ]

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4967

The catch bloack doesn't get executed even when catching the generic Exception object.


Try just catching the RuntimeException, rather than the generic Exception object. You might find the true exception that is being thrown from your Hibernate3 code.

-Cameron McKenzie


Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hibernate JPA persist() not throwing EntityExistsException
 
Similar Threads
Exceptions problem
iPlanet Exception Handling
how to catch exception in EJB
WAS 5.0 - Exception Stack Trace not printed in log file
CMP Exception Handling