Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Many-to-one mapping issue

 
Alana Sparx
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • 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?
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic