Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TENEO] Hibernate update exception when updating existing data
[TENEO] Hibernate update exception when updating existing data [message #606995] Fri, 15 June 2007 09:08
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
Hi,
I have an EMF model which I have persisted into a DB using Teneo and Hibernate. My EMF model is
initially loaded from an XML document and calling save on the root of the object graph will
correctly persist the document into the DB.

In my application I am trying to deal with new xml documents which may contain new elements for
persisting or updates to existing elements which were persisted from previous XML document submissions.

Test 1:

As a basic test I have loaded an initial XML document into my EMF model then persisted this to the
DB. I then attempted to load exactly the same document and perform a session.update() passing in the
root of the object graph . Sounds reasonable, it should overlay the object values on top of the old
ones and increment the version of each persisted object in the DB.

Problem 1:

An exception is thrown of the form

org.hibernate.NonUniqueObjectException: a different object with the same identifier value was
already associated with the session:
[cat.CategoryScheme#urn:sdmx:org.sdmx.infomodel.categorysche me.CategoryScheme=SDMX:categoryScheme1]

I am running this test in isolation so I have created a brand new session from Teneo, then I have
called empty() just to be sure, then when I perform my update( ) I see the error above. Am I missing
somethign here? How can the object possibly already be in the session ?

-----------

Test 2:

I load an initial XML document into my EMF model and persist this through Teneo/Hibernate to the DB.
I then attempt to load a new XML document which contains some new elements and one existing element.
I then call saveOrUpdate on the datagraph root. I would expect in this instance for hibernate to be
able to differentiate between new and existing elements and perform a save or update accordingly.

Problem 2:

An exception is thrown of the form

10:00:40,359 WARN JDBCExceptionReporter:77 - SQL Error: 1062, SQLState: 23000
10:00:40,359 ERROR JDBCExceptionReporter:78 - Duplicate entry
'urn:sdmx:org.sdmx.infomodel.base.Agency=SDMX' for key 1
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update....etc etc

It seems again that hibernate is not differentiating between existing and new objects but this time
it gets further and is attemtping to put the object into the DB, but with a save instead of an
update. Should Teneo/Hibernate be able to handle this mixture of new and existing elements.

-------------

Ive looked through the Hibernate forums extensively on this issue and I cant seem to find any exact
related issues. Im thinking that my problem is more to with EMF and Teneo and the semantics of how
they interact with Hibernate......but I could be on totally the wrong track.

Anyone ever tried anything similiar to the above .. ?

Any help is greatly appreciated as always.

Duncan
Previous Topic:[teneo/jpox] Question of design of metadata
Next Topic:[TENEO] Hibernate update exception when updating existing data
Goto Forum:
  


Current Time: Thu Apr 18 02:06:47 GMT 2024

Powered by FUDForum. Page generated in 0.02131 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top