Hibernate version: 3.2.3 Annotations: 3.3.0 GA
Mapping documents:
package com.foo.bar;
import ...
@Entity(name="Product")
public class Product {
...
}
Code between sessionFactory.openSession() and session.close():
ClassMetadata mData = sessionFactory.getClassMetadata("Product");
mData is always null whereas
ClassMetadata mData = sessionFactory.getClassMetadata("com.foo.bar.Product");
returns the expected ClassMetadata instance.
Info from debug session
I've debugged the app and traced the problem to:
in org.hibernate.cfg.annotations.EntityBinder:
Code:
public void bindEntity() {
persistentClass.setAbstract( annotatedClass.isAbstract() );
persistentClass.setClassName( annotatedClass.getName() );
persistentClass.setNodeName( name );
//persistentClass.setDynamic(false); //no longer needed with the Entity name refactoring?
persistentClass.setEntityName( annotatedClass.getName() );
...
}
Diagnosis
the annotatedClass is an instance of org.hibernate.annotations.common.reflection.XClass its name correctly shows "Product". However, calling the getName() method on that class returns, instead, the fully qualified class name of the mapped entity: "com.foo.bar.Product".
Is this a bug?
I see the need for the fully qualified class name based on how Hibernate's Session's get(Class class, Serializable id); method is implemented, but it seems to me that one could create two entries in the SessionFactoryImpl's classMetadata Map.
Thanks,
Ezra E.