-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Foreign key must have same number of columns as primary key.
PostPosted: Wed Apr 18, 2007 7:57 am 
Newbie

Joined: Wed Mar 28, 2007 2:51 pm
Posts: 16
Wise gurus of hibernate!

I have set up a many-to-many relation between 2 simple classes (and autogenerate my mappings with xdoclet), yet when hibernate runs, it says this:

org.hibernate.MappingException: Foreign key (FKB307E1191A5ADD70:events [fk_report])) must have same number of columns as the referenced primary key (reports [fk_event,fk_report])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:90)


The mirrored index tables for each class look like this (MySQL).

events_reports:

fk_event, fk_report, PRI

reports_events:

fk_report,fk_event, MUL


In my report class I have this annotation:

/**
* @hibernate.set role="events" cascade="save-update" inverse="true" lazy="true"
* @hibernate.collection-key column="fk_report"
* @hibernate.collection-many-to-many column="fk_event" class="mil.darpa.tn.model.EventModel"
* @return
*/
public Collection getEvents() {
return events;
}

And in my event class I have the reverse:

/**
* @hibernate.set role="reports" cascade="save-update"
* @hibernate.collection-key column="fk_event"
* @hibernate.collection-many-to-many column="fk_report" class="mil.darpa.tn.model.ReportModel"
* @return
*/
public Collection getReports() {
return reports;
}


Any tips? I researched this issue and found nothing recent.

Thank you!!
Darren


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.