When Metamodel is created based on hbm xml file mapping then wrong entity name is set for {{MetamodelImpl#entityPersisterMap}} comparing with annotation based one.
Because of that it is impossible to get entity persister by its class for any entity that has configred entity-name in hbm xml file.
After all this one leads to nasty: {code:java} java.lang.IllegalArgumentException: Not an entity [class net . avaleo . business . domain.patient.Patient ] at org.hibernate.internal.SessionImpl.contains(SessionImpl.java:2140) {code}
After deep debugging we found that in {{org.hibernate.boot.model.source.internal.hbm.ModelBinder}} which is responsible for creation of bindings based on hbm xml files {{entity-name}} xml attribute is assigned to {{PersistenceClass#entityName}} class mapping: {code:java} private void bindBasicEntityValues( MappingDocument sourceDocument, AbstractEntitySourceImpl entitySource, PersistentClass pc) { pc.setEntityName( entitySource.getEntityNamingSource().getEntityName() ); pc.setJpaEntityName( entitySource.getEntityNamingSource().getJpaEntityName() ); pc.setClassName( entitySource.getEntityNamingSource().getClassName() ); [...] {code} in opposite to {{org.hibernate.cfg.annotations.EntityBinder}} where a class name is assigned to {{PersistenceClass#entityName}} {code:java} public void bindEntity() { pc.setEntityName( annotatedClass.getName() ); pc.setClassName( annotatedClass.getName() ); pc.setJpaEntityName(name); {code}
|
|