Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] MappingException on embedded object after save/refresh/save cycle on parent object
[Teneo] MappingException on embedded object after save/refresh/save cycle on parent object [message #1707005] Tue, 01 September 2015 12:39 Go to next message
Phil B is currently offline Phil BFriend
Messages: 7
Registered: February 2012
Junior Member
Hello,
I have an RCP project with an EMF model that contains a Whole class, which in turn refers to a Part. The reference is a containment reference, annotated with @Embedded. The Part class is annotated with @Embedded, it has a single property which is an Integer.

The application loads objects from the database and then places them into HibernateResources.

When the application subsequently calls:
parentResource.save(...);

then a bit later...
session.refresh(parent); // Refresh is cascaded

and later still...
parentResource.save(...);

I get:

org.hibernate.MappingException: Unknown entity: Part
org.hibernate.internal.SessionFactoryImpl.getEntityPersister (SessionFactoryImpl.java:1096)
...
org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved (foreignKeys.java:293)
org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierUtil.getID (IdentfierUtil.java:143)
org.eclipse.emf.teneo.resource.StoreResource.save (StoreResource.java:422)
...

From stepping through in the debugger I can see that when the application calls Session.refresh(parent) Hibernate replaces the original Part object with a new Part with the same value as the original. When this happens EMF and the StoreResource move the original Part to the StoreResource's removeEObjects collection.

Then later, when the 2nd save occurs, HibernateResource#saveResource attempts to get an identifier for the deleted object so that it can delete it. Unfortunately the Part appears as a component in the Hibernate mapping rather than an entity, and so has no id, and at this point Hibernate throws the MappingException.

I don't think that the HibernateResource should try to delete the original Part object as it is a component, but maybe I'm missing something.

I'm using Teneo 2.1.0 and hibernate 4.3.5

Apologies for the lack of concrete code and stack trace, my development environment is not connected to the internet.

Thanks
Phil
Re: [Teneo] MappingException on embedded object after save/refresh/save cycle on parent object [message #1707058 is a reply to message #1707005] Tue, 01 September 2015 22:09 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Phil,
Seems to be a bug, no delete should happen as you say. Can you create a bugzilla and attach an example ecore model to it?

gr. Martin

On 01-09-15 14:39, Phil B wrote:
> Hello,
> I have an RCP project with an EMF model that contains a Whole class, which in turn refers to a Part. The reference is a
> containment reference, annotated with @Embedded. The Part class is annotated with @Embedded, it has a single property
> which is an Integer.
>
> The application loads objects from the database and then places them into HibernateResources.
>
> When the application subsequently calls:
> parentResource.save(...);
>
> then a bit later...
> session.refresh(parent); // Refresh is cascaded
>
> and later still...
> parentResource.save(...);
>
> I get:
>
> org.hibernate.MappingException: Unknown entity: Part
> org.hibernate.internal.SessionFactoryImpl.getEntityPersister (SessionFactoryImpl.java:1096)
> ...
> org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved (foreignKeys.java:293)
> org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierUtil.getID (IdentfierUtil.java:143)
> org.eclipse.emf.teneo.resource.StoreResource.save (StoreResource.java:422)
> ...
>
> From stepping through in the debugger I can see that when the application calls Session.refresh(parent) Hibernate
> replaces the original Part object with a new Part with the same value as the original. When this happens EMF and the
> StoreResource move the original Part to the StoreResource's removeEObjects collection.
>
> Then later, when the 2nd save occurs, HibernateResource#saveResource attempts to get an identifier for the deleted
> object so that it can delete it. Unfortunately the Part appears as a component in the Hibernate mapping rather than an
> entity, and so has no id, and at this point Hibernate throws the MappingException.
>
> I don't think that the HibernateResource should try to delete the original Part object as it is a component, but maybe
> I'm missing something.
>
> I'm using Teneo 2.1.0 and hibernate 4.3.5
>
> Apologies for the lack of concrete code and stack trace, my development environment is not connected to the internet.
>
> Thanks
> Phil


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] MappingException on embedded object after save/refresh/save cycle on parent object [message #1707121 is a reply to message #1707058] Wed, 02 September 2015 13:01 Go to previous messageGo to next message
Phil B is currently offline Phil BFriend
Messages: 7
Registered: February 2012
Junior Member
will do
Re: [Teneo] MappingException on embedded object after save/refresh/save cycle on parent object [message #1707496 is a reply to message #1707121] Sat, 05 September 2015 21:18 Go to previous message
Phil B is currently offline Phil BFriend
Messages: 7
Registered: February 2012
Junior Member
I've created https://bugs.eclipse.org/bugs/show_bug.cgi?id=476710
Previous Topic:EMF stand-alone SWT problems
Next Topic:[EEF] Default EEF model initialization
Goto Forum:
  


Current Time: Fri Apr 19 19:00:06 GMT 2024

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

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

Back to the top