File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Foreig key must have same number of columns as the referenced primary key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Foreig key must have same number of columns as the referenced primary key" Watch "Foreig key must have same number of columns as the referenced primary key" New topic
Author

Foreig key must have same number of columns as the referenced primary key

Mafada Yeah
Greenhorn

Joined: Jan 13, 2012
Posts: 1
Hello!

I developing a web application with NetBeans. I'm trying to integrate hibernate into my project in order to set/get information from Database.

After create the Hibernate Reverse Engigeering file and Mapping Files, using NetBEans wizard, I found one proplem executing HQL:
org.hibernate.MappingException: Foreign key (FK637007E11D64F93:muxes [location_id])) must have same number of columns as the referenced primary key (locations [name,network_name,network_type_id,country_id])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:90)
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:73)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1263)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:324)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)

My table locations has 4 columns for primary key, but my table muxes has reference to location id in order to be unique, i don't know how to solve this problem.

And the maping files are:
Muxes.hbm.xml

Locations.hbm.xml


Can someone help meee???
Thanks!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Foreig key must have same number of columns as the referenced primary key
 
Similar Threads
Hibernate many to one composite primary key consisting foreign key
Foreign key must have same number of columns
Association references unmapped class exception with hibernate
Problem with Hibernate composite key mapping
Please explain me the hibernate generated sql queries in console