-->
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: detecting duplicate insert
PostPosted: Sat Mar 13, 2004 1:27 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
what is the preferred way of dectecting a duplicate insert since most hibernate methods throw hibernate expection .. do I check the error code ? Based on this I would like to re-throw the expection as specialized form of a dataaccessexception .. such as a duplicatekeyexception.



Thanks
Serge


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 12:32 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is not common method unfortunatly.
This kind of root exception is DB vendor specific. So you'll need to do :
- try to read the entry before inserting it if you expect a high rate of failure
- check the exception cause hierarchy to find your DB specific exception and rethrow your business exception.

I know this could be a cool feature to abstract from the DB, but it probably has to come from the JDBC spec :(

_________________
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.