-->
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.  [ 4 posts ] 
Author Message
 Post subject: ConstraintViolation - duplicate key on re-save.
PostPosted: Mon Apr 30, 2007 4:21 pm 
Newbie

Joined: Wed Mar 28, 2007 2:51 pm
Posts: 16
Hi,
I have a many to many mapping between Reports and Events and I can save my Report objects fine, and the Events get saved and associated through "reports_events" table.

But if I do that once, then try to save an Event object that was related to a Report already, I cannot save the Event object by itself. It complains the key is already there. Of course it is, but I want to update it if it is, save it new if it isn't.

Any tips on this greatly appreciated. Thanks!!!

Darren


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 30, 2007 11:46 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Can you show the exception?

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 1:12 pm 
Newbie

Joined: Wed Mar 28, 2007 2:51 pm
Posts: 16
(util.JDBCExceptionReporter 77 ) SQL Error: 1062, SQLState: 23000
(util.JDBCExceptionReporter 78 ) Duplicate entry '1f885a0531debd2b:-1e2164ce:112489fab56:-7ffe' for key 1
(def.AbstractFlushingEventListener 301 ) Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update


Thanks for any ideas. There is an association between a Report<->Event already, but I want to save the Event object independently, after saving it before already.

Does hibernate require I use update after an initial save or is it smart enough to know?

Darren


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 1:18 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Try saveOrUpdate()

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.