-->
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: FK must have same number of column as referenced in PK
PostPosted: Wed Aug 10, 2016 7:18 am 
Newbie

Joined: Wed Aug 10, 2016 7:04 am
Posts: 2
Hi
I have the following tables
one to many relation between Header and Detail
Detail has zero or one record in Replay

The problem is because Detail has got 5 property composite key as pk i am unable to map to Graphic table which has got only 3 of the property from the composite key to map, to get the GRAPHICCODE.
And i keep getting ...must have same number of columns as the referenced primary key...
I am really struggling with how to achieve this.

Basically the output i am trying to achieve is:

ProductNumber ColorCode SizeCode GraphicCode
12345 AAA SM TTTT
12345 AAA MD TTTT
12345 BBB SM TTTT
12345 BBB MD TTTT

Header: -> PROGCD+CHCD acts as compositekey to make pk
PROGCD
CHCD

Detail:
PROGCD
CHCD
PRODCD
COLORCD
SIZECD
AMOUNT

Replay:
PROGCD
CHCD
PRODCD
COLORCD
SIZECD
PRICE
POSTAGE

Graphic:
PROGCD
CHCD
PRODCD
GRAPHICCODE

Can anyone please help me how to solve this?

Many Thanks
Ela


Top
 Profile  
 
 Post subject: Re: FK must have same number of column as referenced in PK
PostPosted: Wed Aug 10, 2016 8:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
You can have the PK in Graphic using those 3 columns, and the have a mapping in Details which uses the same 3 columns to form a foreign key, therefore a @ManyToOne association.


Top
 Profile  
 
 Post subject: Re: FK must have same number of column as referenced in PK
PostPosted: Wed Aug 10, 2016 8:42 am 
Newbie

Joined: Wed Aug 10, 2016 7:04 am
Posts: 2
Thanks for the reply.

But there could be zero records in graphic. So can't have the pk in graphic table. Only relation could be is between Header -> Detail -> Graphic


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.