-->
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: Composite Id Entity with a One-To-Many Mapping
PostPosted: Thu May 20, 2010 10:26 am 
Newbie

Joined: Thu May 20, 2010 10:10 am
Posts: 1
Hi,
i need an help to solve this kind of Entity Mapping.

First Entity: CityProvider
Composite Id: idProvider; idCity
column: idCountry

Second Entity: Country
Composity Id: idCountry, language

I need a one-to-many mapping between CityProvider and Country.

I tried this hbm file for CityProvider:
...
<composite-id
name="cityProviderId"
class="it.newmedia.bravofly.backoffice.common.data.hibernate.beans.CityProviderId"
unsaved-value="any"
>
<key-property
name="idProvider"
type="java.lang.Integer"
column="ID_PROVIDER"
/>

<key-property
name="idCity"
type="java.lang.String"
column="ID_CITY"
/>
</composite-id>
<set
name="cityProviderLanguageCountries"
table="Country"
lazy="false"
cascade="none"
sort="unsorted"
>
<key
>
<column
name="ID_PROVIDER"
/>
<column
name="ID_CITY"
/>
<column
name="ID_COUNTRY"
/>
</key>
<one-to-many class="Country"/>
</set>
...

but I obtain this error:
"Foreign key ... must have same number of columns as the referenced primary key ..."

Thank you in advance for any help.


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.