• 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

Many-to-one mapping issue

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

I'm writing a hibernate mapper for an existing database, and only need to use a handful of objects from this db.

When I run my test, I keep getting the following error:
Foreign key (FK5E0F67F881B2AA8:group [group_code]))
must have same number of columns as the
referenced primary key (group [ec_env,group_code])


The group.hbm.xml lookslike


The group model object & xdoclet tags looks like:



The composite key of group is a foreign key of two other db objects that I haven't modelled, could this be the issue?
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alana,

From what I understand you have a composite key as a primary key for your Group Entity. If CcRecepient has a foreign key constraint on Group it has be be on both those keys(group_code and ecEnv). The composite key defines uniqueness in our Group table. I think you cannot just use groupCode but should use the composite key.

Hope this helps.
 
For my next feat, I will require a volunteer from the audience! Perhaps 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