| Summary: | Error in entity name computation in case of Dynamic EMF extending Static EMF | ||
|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Martin Taal <mtaal> |
| Component: | Teneo | Assignee: | Martin Taal <mtaal> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 1.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
Fixed in build of 1 Nov 2011 |
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))