-->
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: Problem 1 Foreign Key include 2 fields.
PostPosted: Thu May 10, 2007 6:57 am 
Newbie

Joined: Tue Mar 13, 2007 1:01 am
Posts: 14
I have a table A which has 1 foreign key (this foreign key include 2 fields which are primary of another table B)

But I dot no how to map this in persistent class and mapping file.

I receive the following error when running.
Error :
Foreign key in table A must have same number of columns as referenced primary key in table B.

Pls tell me how to do that.

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 8:12 am 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
Look at composite-id (don't forget to override equals and gethashmap).

It should look like your database, so parent table A should have a composite-id. Child table B should have a many-to-one defined with two columns.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 10:23 pm 
Newbie

Joined: Tue Mar 13, 2007 1:01 am
Posts: 14
I understand your solution but i don't know how to implement this. Could you give me an example ?

Thanks in advance.


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.