Community
Participate
Working Groups
Created attachment 256403 [details] Project demonstrating refresh problem 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 @Embeddable, 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(whole); // Refresh is cascaded and later still... wholeResource.save(...); I get: org.hibernate.MappingException: Unknown entity: Part at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096) at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1452) at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:242) at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:293) at org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierUtil.getID(IdentifierUtil.java:143) at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:390) at 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(whole) 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 is 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. I'm using Teneo 2.1.0 and hibernate 4.3.5 The attached project demonstrates the problem. Instructions for running the project are in the description of the pom.xml.