-->
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: mapping 2 tables with composite key returns an error
PostPosted: Wed May 31, 2006 7:38 am 
Newbie

Joined: Wed May 31, 2006 7:19 am
Posts: 1
Hello all,

I have 2 tables with composite key's

PRODUCT_VERSIONS:
PRODUCT_ID NOT NULL NUMBER(38)
PRODUCT_VERSION NOT NULL VARCHAR2(10)

which has one to many mapping to

SHELVES_PRODUCT:
PRODUCT_ID NOT NULL NUMBER(38)
PRODUCT_VERSION NOT NULL VARCHAR2(10)
SHELF_ID NOT NULL NUMBER(38)

each product version has many shelves

but I get an error and I dont understand why:

Foreign key (FK60ADE117BF964528:LB_SHELVES_PROD [SHELF_ID])) must have same number of columns as the referenced primary key (LB_PRODUCTS_VER [PRODUCT_ID,PRODUCT_VERSION])

Hibernate version: 3.0

Mapping documents:

<class name="com.softlib.LB.classes.version" table="LB_PRODUCTS_VER">

<composite-id name="Vpk" class="com.softlib.LB.classes.versionPK">
<key-property name="product_id">
<column name="PRODUCT_ID" sql-type="number(38)" not-null="true"/>
</key-property>
<key-property name="name">
<column name="PRODUCT_VERSION" sql-type="varchar2(10)" not-null="true"/>
</key-property>
</composite-id>

<many-to-one name="productObject" insert="false" update="false"
class="com.softlib.LB.classes.product"
column="PRODUCT_ID" />

<set name="shelves_products" table="LB_SHELVES_PROD" inverse="true" cascade="all">
<key>
<column name="PRODUCT_ID"/>
<column name="PRODUCT_VERSION"/>
</key>

<one-to-many class="com.softlib.LB.classes.shelves_products"/>
</set>



</class>




<class name="com.softlib.LB.classes.shelves_products" table="LB_SHELVES_PROD">

<composite-id>
<key-property name="product_id">
<column name="PRODUCT_ID" sql-type="number(38)" not-null="true"/>
</key-property>
<key-property name="name">
<column name="PRODUCT_VERSION" sql-type="varchar2(10)" not-null="true"/>
</key-property>
<key-many-to-one name="shelfObject" class="com.softlib.LB.classes.shelf">
<column name="SHELF_ID"/>
</key-many-to-one>
</composite-id>


</class>




Name and version of the database you are using: Oracle 8i

_________________
cheers and thanks in advance,
Yaniv David.


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.