This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Hibernate JPA persist() not throwing EntityExistsException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
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: 4968
    
    1

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate JPA persist() not throwing EntityExistsException