We have defined multiple mapping files using the same class for loading from multiple tables.
To do this with specify a different entity-name for each mapping we do.
the problem seems to be that when using a <join> to load an attribute of our object from another table, the HbmBinder class use the entityName to bind the property to the class instance and return a MappingException that says:
org.hibernate.MappingException: class
entityName not found while looking for property:
propertyName
Looking in HbmBinder code at line 957 I've seen the following:
Code:
if ( value != null ) {
Property prop = createProperty( value, propertyName, persistentClass
.getEntityName(), subnode, mappings, inheritedMetas );
prop.setOptional( join.isOptional() );
join.addProperty( prop );
}
shouldn't it be:
Code:
if ( value != null ) {
Property prop = createProperty( value, propertyName, persistentClass
.getClassName(), subnode, mappings, inheritedMetas );
prop.setOptional( join.isOptional() );
join.addProperty( prop );
}
I changed from
persistentClass.getEntityName() to
persistentClass.getClassName()
becuase the createProperty method is using value.setTypeUsingReflection( className, propertyName ); and here we need the name of the class....
what do you think?
am I completely wrong?
I also found another post that is caused by the same error (I think). here is the link:
http://forum.hibernate.org/viewtopic.php?t=941379
I've tested this with Hibernate 3.1, 3.1.2 and 3.1.3... always the same MappingException
If I don't write the entityName in the mapping file everything works perfectly.
I hope somebody can give me some help or suggest a workaround for using entityNames and <join> together.
thanks in advance!
[/i]