This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a composite-id with 2 columns, only one of them is a foreign key to another table

 
Wassim Melhem
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

So I am kinda new to hibernate and it's been days I'm trying to solve this problem I am getting with the mapping, hope someone can help

I tried to search a lot, found lots of similar questions but none really applying to my case. I have a table TABLE1 which has an index "id" and another table which has as index (TABLE1_ID and NUMBER). Only TABLE1_ID is a foreign key while number doesn't reference anything specific

TABLE 1 has the following hibernate mapping




I am not sure what should be the mapping for the other table. I did it the following way



Please note that I created the class TABLE1TABLE2Id after I read somewhere that there should be some intermediate mapping.

I am sure there's something wrong or missing from TABLE2 mapping (I am not so advanced with hibernate) but when trying to install the app, I am getting the following error
Foreign key (TABLE1 [id]) must have same number of columns as the referenced primary key (TABLE2 [TABLE1_ID, NUMBER])

I appreciate anybody's help thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic