I have not had a chance to look into whether or not the issue is with Xdoclet (I am using a 1.3 snapshot), but I think the problem may also reside in Hibernate itself. Using XDoclet to generate the Hibernate mapping files and for a one-to-one mapping in the child class, the resulting relavent hbm file is as follows:
<generator
class="foreign"
>
<param name="property">
<![CDATA[user]]>
</param>
</generator>
When I attempt to save the parent object and the save cascades to the child object with the above contained mapping file, the resulting error is along the lines of:
Unable to resolve property: <white space>user<whitespace>
This is triggered in the call to getPropertyIndex within tuple/EntityMetamodel.java.
Specifically looking into the propertyName being requested, it is indeed the string "user" pre- and post-pended with whitespace. The whitespace should really be trimmed.
I found one of two fixes to this. First, hand editting the hbm file generated by xdoclet to read:
<generator
class="foreign"
>
<param name="property">user</param>
</generator>
Or, edit the Hibernate source, specifically around line 1964 of cfg/HbmBinder.jave from:
Iterator iter = subnode.elementIterator( "param" );
while ( iter.hasNext() ) {
Element childNode = (Element) iter.next();
params.setProperty( childNode.attributeValue( "name" ), childNode.getText() );
}
TO:
Iterator iter = subnode.elementIterator( "param" );
while ( iter.hasNext() ) {
Element childNode = (Element) iter.next();
params.setProperty( childNode.attributeValue( "name" ), childNode.getTextTrim() );
}
In otherwords, calling getTextTrim() on the childNode. getTextTrim is used in a number of other instances. Is this the proper fix? Or is there something else that also needs to be addressed with Xdoclet?
Thanks
-jim spring
|