-->
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.  [ 2 posts ] 
Author Message
 Post subject: (Newbie question) create Set to PK of other class
PostPosted: Thu Aug 25, 2005 4:44 pm 
Beginner
Beginner

Joined: Wed Jul 20, 2005 2:57 pm
Posts: 28
Hi,

I have trouble with my set. I want to create a Set to another class.
Here are the two mappingfiles I tried to do that with:

Quote:
<hibernate-mapping package="hibernate">
<class
name="Team"
table="team"
>
<composite-id name="pk_team" class="PK_Team">
<key-property
name="leagueid"
column="leagueid"
type="java.lang.Long"
/>
<!-- teamname-->
<key-property
name="name"
column="name"
type="java.lang.String"
/>
</composite-id>
<set name="Team_Player" inverse="true" cascade="all">
<key column="leagueid"/>
<key column="teamname"/>
<one-to-many class="hibernate.Player"/>
</set>

...
</hibernate-mapping>



and the mapping of the "child-class" looks like this:
Quote:
<hibernate-mapping package="hibernate">
<class
name="Player"
table="player"
>
<composite-id name="pk_player" class="PK_Player">
<key-property
name="leagueid"
column="leagueid"
type="java.lang.Long"
/>
<key-property
name="teamname"
column="teamname"
type="java.lang.String"
/>
<!-- playername-->
<key-property
name="name"
column="name"
type="java.lang.String"
/>
</composite-id>
...
</hibernate-mapping>


Any help is greatly appreciated.

Regards,
Kurt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 6:14 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
I think you just need to put two column tags in the key tag, rather than have two key tags. Here's an example from the docs (http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#components-compositeid)

Code:
<set name="orderLines" inverse="true">
    <key>
        <column name="orderId"/>
        <column name="customerId"/>
    </key>
    <one-to-many class="OrderLine"/>
</set>


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

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.