Hibernate version: Hibernate EntityManager 3.2.0.CR1
Mapping documents:
Code:
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0">
<embeddable class="Incident$IncidentId" access="FIELD" metadata-complete="true">
</embeddable>
</entity-mappings>
Full stack trace of any exception that occurs:Caused by: org.hibernate.AnnotationException: Unable to load class defined in XML: .Incident$IncidentId
at org.hibernate.cfg.AnnotationConfiguration.add(AnnotationConfiguration.java:493)
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:573)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:818)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:653)
at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:148)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:202)
... 4 more
Caused by: java.lang.ClassNotFoundException: /Incident$IncidentId
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112) at org.hibernate.reflection.java.JavaXFactory.classForName(JavaXFactory.java:101)
at org.hibernate.cfg.AnnotationConfiguration.add(AnnotationConfiguration.java:490)
... 9 more
I think this is caused by the following code in XMLContext.java
http://fisheye.labs.jboss.com/browse/~raw,r=10187/Hibernate/trunk/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/XMLContext.javaCode:
public static String buildSafeClassName(String className, String defaultPackageName) {
if ( className.indexOf( '.' ) < 0 && defaultPackageName != null ) {
className = StringHelper.qualify( defaultPackageName, className );
}
return className;
}
It checks against null, where as in the following code, packagename defaults to "".
Code:
//entity mapping default
Default entityMappingDefault = new Default();
Element unitElement = root.element( "package" );
String packageName = unitElement != null ? unitElement.getTextTrim() : "";
Thanks,
Sahoo