IntelliJ Java IDE
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
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply 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!!!
 
 
subject: Foreig key must have same number of columns as the referenced primary key
 
Threads others viewed
Foreign key must have same number of columns
Hibernate many to one composite primary key consisting foreign key
Problem with Hibernate composite key mapping
Association references unmapped class exception with hibernate
Please explain me the hibernate generated sql queries in console
MyEclipse, The Clear Choice