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: Updating DB with detached objects
PostPosted: Fri Jun 15, 2007 6:39 am 
Newbie

Joined: Fri Jun 15, 2007 6:25 am
Posts: 2
Hi,
Im having a problem with updating my DB with detached objects that have been edited. I have looked extensively through the forum archives for someone with similiar issues and although they have appeared I havent seen any replies which could help.

I have an application which reads in XML documents into an Object Graph and persists them into a DB via Hibernate. Unique objects in the XML and in the object graph are identified by a URN which acts as the hibernate key.

One of the requirements of the aplication is that updates can be made to the database by submitting an XML document which includes updated versions of existing objects and new objects.

Im treating my object graphs as detached objects which have been edited and had new objects added to them.

Im using the saveOrUpdate command to try and persist these new object graphs into the DB but I repeatedly get errors of the sort:

10:57:02,765 WARN JDBCExceptionReporter:77 - SQL Error: 1062, SQLState: 23000
10:57:02,765 ERROR JDBCExceptionReporter:78 - Duplicate entry 'urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=SDMX:conceptSc' for key 1

org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)...etc etc

It would appear that Hibernate is trying to save all of my objects as if they were new objects even though some of them already exist in the DB hence my use of saveOrUpdate. Am I misunderstanding the use of this method. ?

Any help is greatly appreciated as always.

regards

Duncan


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.