Hi
my tables look like
Table A (primary key is composite of columns X, Y)
Table B( primary Key is composit of X, Y, Z) with a composite forign key (X, Y) refrences A(X,Y)
The A.xml files genrated by middlegen looks fine, in the set definition I can see TWO columns
<set
name="Bs"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="X"
@hibernate.collection-key
column="Y"
@hibernate.collection-one-to-many
class="com.Hibernate.B"
</meta>
<key>
<column name="X" />
<column name="Y" />
</key>
<one-to-many
class="com.Hibernate.B"
/>
</set>
In my build.xml I am doing:
- middlegen to get the xml from the datbase
- hbm2java
- hibernatedoclet
By looking at the xml files genrated in the final step .... the second column in my set has disappered
<set
name="Bs"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="X"
>
</key>
<one-to-many
class="com.Hibernate.B"
/>
</set>
On hibernate startup I am getting the following exception
collection foreign key mapping has wrong number of columns: com.Hibernate.A.Bs type:
com.Hibernate.APK
It looks like hibernate is trying to resolve the type of Bs which depend on the key of A but the number of supplied colums is not enough [ A's key is a composite key]
I tried to specify the outher colums as another <key> entry in the set but
[ERROR] XMLHelper - -Error parsing XML: XML InputStream(401) The content of element type "set" must match "(meta*,(cache|jcs-cache)?,key,(element|one-to-many|many-to-many|composite-element|many-to-any))".
My build file for generating the hibernatedoclet
looks like
<!-- =================================================================== -->
<!-- Invoke XDoclet's hibernate -->
<!-- =================================================================== -->
<target name="hibernate" depends="init" description="Generate mapping documents (run jar first)">
<echo>Creating .hbm.xml files from .java files using xdoclet</echo>
<hibernatedoclet
destdir="${build.gen-src.dir}"
mergedir="${build.gen-src.dir}"
excludedtags="@version,@author,@todo,@see"
addedtags="@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version}"
verbose="false">
<fileset dir="${build.gen-src.dir}">
<include name="**/*.java"/>
</fileset>
<hibernate version="2.0"/>
</hibernatedoclet>
</target>
|