-->
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.  [ 1 post ] 
Author Message
 Post subject: Reset Id's, generated by hibernate, if insert fails
PostPosted: Mon Sep 28, 2009 2:26 am 
Newbie

Joined: Fri Sep 11, 2009 10:15 am
Posts: 8
Hi,

i have the following problem:
- user enters data into a form
- form data is stored inside a java object
- saveOrUpdate is called; now the insert of the new object fails due to
a unique constraint violation
- the user corrects his data and tries again to store the data

The problem is, when saveOrUpdate is called again, hibernate tries to update the database instead of an insert, cause
the id of the object is already set.
Right now my workaround is to copy the complete object-graph and reset my object if the insert fails.

Is there any "cleaner" hibernate solution to reset the generated id's? (Or is there any better solution then to use saveOrUpdate?)

Best regards

peter


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

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.