-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: On-to-Many relation with composite key
PostPosted: Thu Nov 11, 2004 11:00 am 
Newbie

Joined: Thu Nov 11, 2004 10:34 am
Posts: 1
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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.