• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
No more fooling around. Read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic