The moose likes Object Relational Mapping and the fly likes Many-to-one mapping issue Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Many-to-one mapping issue" Watch "Many-to-one mapping issue" New topic
Author

Many-to-one mapping issue

Alana Sparx
Ranch Hand

Joined: Feb 14, 2006
Posts: 121
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

Joined: Oct 17, 2001
Posts: 153
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.


Shailesh Kini.
 
 
subject: Many-to-one mapping issue
 
Threads others viewed
Hibernate and a Table called [group] - problem
@ManyToOne & @JoinColumn
XMLEncoder not serializing the whole graph!
parameter not set!
Adding data using hibernate for Composite primary keys
developer file tools