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
|