-->
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.  [ 3 posts ] 
Author Message
 Post subject: Help with -> MappingException: Foreign key...
PostPosted: Tue Sep 06, 2005 6:18 am 
Newbie

Joined: Tue Sep 06, 2005 6:09 am
Posts: 2
I'm starting to work with Hibernate 3. And when I Tray to access a information in DataBase, Hibernate print this exception:

org.hibernate.MappingException: Foreign key (FK7089409D6A199C:TABLE_A [COLUMN_B])) must have same number of columns as the referenced primary key (TABLE_B [COLUMN_A,COLUMN_B,COLUMN_C,COLUMN_D,COLUMN_E])

I think that the *.Class an *.hbm.xml, which I generated, are correct (Im using for genereted MyEclipse plugin). And the Data Model is correct.

Please, ¿Cant help me?


Top
 Profile  
 
 Post subject: Re: Help with -> MappingException: Foreign key...
PostPosted: Tue Sep 06, 2005 6:25 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
Hi,

ijgomez wrote:
I think that the *.Class an *.hbm.xml, which I generated, are correct (Im using for genereted MyEclipse plugin). And the Data Model is correct.

It might be very helpful if you could provide the significant extracts of the files you mention.

I would suspect the problem to be there - and should it be a Hibernate problem then having this information makes it easier to reproduce the "bug".

Erik


Top
 Profile  
 
 Post subject: Re: Help with -> MappingException: Foreign key...
PostPosted: Tue Sep 06, 2005 6:48 am 
Newbie

Joined: Tue Sep 06, 2005 6:09 am
Posts: 2
ErikFK wrote:
Hi,

ijgomez wrote:
I think that the *.Class an *.hbm.xml, which I generated, are correct (Im using for genereted MyEclipse plugin). And the Data Model is correct.

It might be very helpful if you could provide the significant extracts of the files you mention.

I would suspect the problem to be there - and should it be a Hibernate problem then having this information makes it easier to reproduce the "bug".

Erik


Hi,

the significant extracts of the *.hbm.xml files is:

TableA.hbm.xml:
Code:
....
    <class name="TableA" table="TABLE_A">
        <composite-id name="id" class="TableAKey">
            <key-many-to-one name="tableB2" column="COLUMN_A" class="TableB"/>
            <key-many-to-one name="tableB1" column="COLUMN_B" class="TableB"/>
            <key-many-to-one name="tableB5" column="COLUMN_C" class="SigmatMedidaPume15"/>
            <key-many-to-one name="tableB3" column="COLUMN_D" class="TableB"/>
            <key-many-to-one name="tableB4" column="COLUMN_E" class="TableB"/>
        </composite-id>
....
    </class>


TableB.hbm.xml:
Code:
...
    <class name="TableB" table="TABLE_B">
        <composite-id name="id" class="TableBKey">
            <key-many-to-one name="columnA" column="COLUMN_A" class="TableCC"/>
            <key-many-to-one name="columnB" column="COLUMN_B" class="TableDD"/>
            <key-many-to-one name="columnC" column="COLUMN_C" class="TableEE"/>
            <key-property name="columnD" column="COLUMN_D" type="java.util.Date"/>
            <key-property name="columnE" column="COLUMN_E" type="java.lang.String"/>
        </composite-id>

.....
.....

        <set name="tableASet" inverse="true">
            <key column="COLUMN_A"/>
            <one-to-many class="TablaA"/>
        </set>

        <set name="tableA1Set" inverse="true">
            <key column="COLUMN_B"/>
            <one-to-many class="TablaA"/>
        </set>

        <set name="tableA2Set" inverse="true">
            <key column="COLUMN_C"/>
            <one-to-many class="TablaA"/>
        </set>

        <set name="tableA3Set" inverse="true">
            <key column="COLUMN_D"/>
            <one-to-many class="TablaA"/>
        </set>

        <set name="tableA4Set" inverse="true">
            <key column="COLUMN_E"/>
            <one-to-many class="TablaA"/>
        </set>

    </class>
...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.