Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362601

Summary: Error in entity name computation in case of Dynamic EMF extending Static EMF
Product: [Modeling] EMF Reporter: Martin Taal <mtaal>
Component: TeneoAssignee: Martin Taal <mtaal>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Martin Taal CLA 2011-11-01 16:57:21 EDT
In the following case the EMFTuplizer will determine an incorrect entityname:

See description by user:

Today I tried to create a mapping that uses single table per hierarchy that have a concrete EMF class as a base and then all subclasses are dynamic EMF classes.

I found out that the hibernate treated all instances as of they were from the base class and not from the subclasses - e.g. all properties that are set in the subclasses are not persisted and the discriminator value that is used is from the base (root) class. Digging more into this issue I found out that the following method on EMFTuplizer class

public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) {
final Class<?> concreteEntityClass = entityInstance.getClass();
if (concreteEntityClass == getMappedClass()) {
return getEntityName();
} else {
String entityName = getEntityMetamodel().findEntityNameByEntityClass(concreteEntityClass);
if (entityName == null) {
throw new HibernateException("Unable to resolve entity name from Class ["
+ concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + getEntityName()
+ "]");
}
return entityName;
}
}


returns always the entity name for the root EMF class because the getMappedClass() is always equal to the concreteEntityClass ( note that when I create a objects from subclasses the actual base class will be the implementation class of the root EMF class (the one that is generated - not dynamic))
Comment 1 Martin Taal CLA 2011-11-01 17:39:11 EDT
Fixed in build of 1 Nov 2011