-->
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: Foreign key does not have all the columns in Primary key
PostPosted: Fri Mar 12, 2010 11:50 am 
Newbie

Joined: Fri Mar 12, 2010 11:37 am
Posts: 1
Table A
--------
Primary key in DB and mapping file is composite-id of LossNumber,LossDate,Currency columns.

Table B
--------
There is no primary key in DB. Mapping file has RunNumber as primary key. This table also has LossNumber,LossDate columns, but it does not have Currency columns.

The relationship from A to B is based on the first 2 columns in primary ID of Table A. For a given LossNumber,LossDate in Table A, there can be more than one record in Table B.

I am interested only in the relationship of A to B and not vice versa.

My mapping file for table A is

Code:
<class table="TableA" name="tableA">
        <composite-id class=TableA" name="TableAPrimaryKey">
            <key-property column="LOSS_NUMBER" type="java.lang.String" name="lossNumber"/>
            <key-property column="LOSS_DATE" type="java.lang.Short" name="lossDate"/>
            <key-property column="CURRENCY" type="java.lang.String" name="curCode"/>
        </composite-id>
           .......
      .......

        <set order-by="RUN_NUMBER" table="TableB" name="tableBrecords">         
            <key>
                <column name="LOSS_NUMBER"/>
                <column name="LOSS_DATE"/>               
            </key>   
            <one-to-many not-found="ignore" class="TableB"/>
        </set>
    </class>


Above mapping file gives me an error which says "Foreign key must have same number of columns as the referenced primary key"


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.