[Teneo] MappingException on embedded object after save/refresh/save cycle on parent object [message #1707005] |
Tue, 01 September 2015 12:39 |
Phil B 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 |
Martin Taal 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02870 seconds