• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get this error every time I try to compile...
Caused by: org.hibernate.MappingException: Foreign key (prd_id:product [prvd_prd_id])) must have same number of columns as the referenced primary key (product_vendor_details [ven_id,prvd_vendor_id])

Can someone please explain? Thanks in advance

Vendor table and xml:
CREATE TABLE `vendor` (
`ven_id` bigint(20) NOT NULL AUTO_INCREMENT,
`ven_clinic_id` bigint(20) DEFAULT NULL,
`ven_name` varchar(20) NOT NULL,
`ven_address` varchar(100) NOT NULL,
`ven_city` varchar(30) NOT NULL,
`ven_state` varchar(30) NOT NULL,
`ven_country` varchar(30) NOT NULL,
`ven_pin` int(11) NOT NULL,
`ven_web_site` varchar(30) DEFAULT NULL,
PRIMARY KEY (`ven_id`),
KEY `FK_vendor` (`ven_clinic_id`),
CONSTRAINT `FK_vendor` FOREIGN KEY (`ven_clinic_id`) REFERENCES `client` (`clt_clinic_id`)
)


Vendor Contact table & xml:

Create Table

CREATE TABLE `vendor_contact_details` (
`vcd_id` bigint(20) NOT NULL AUTO_INCREMENT,
`vcd_vendor_id` bigint(20) DEFAULT NULL,
`vcd_title` varchar(5) DEFAULT NULL,
`vcd_name` varchar(20) DEFAULT NULL,
`vcd_phone` varchar(20) DEFAULT NULL,
`vcd_ext` int(11) DEFAULT NULL,
`vcd_remarks` varchar(100) DEFAULT NULL,
`vcd_email_id` varchar(50) DEFAULT NULL,
PRIMARY KEY (`vcd_id`)
)


Product table & xml:
CREATE TABLE `product` (
`prd_id` bigint(20) NOT NULL AUTO_INCREMENT,
`prd_clinic_id` bigint(20) DEFAULT NULL,
`prd_name` varchar(20) DEFAULT '',
`prd_description` varchar(100) DEFAULT NULL,
PRIMARY KEY (`prd_id`),
KEY `FK_product_clinic_id` (`prd_clinic_id`),
CONSTRAINT `FK_product_clinic` FOREIGN KEY (`prd_clinic_id`) REFERENCES `clinic` (`cln_id`)
)
REATE TABLE `product_vendor_details` (
`prvd_id` bigint(20) NOT NULL AUTO_INCREMENT,
`prvd_prd_id` bigint(20) NOT NULL,
`prvd_vendor_id` bigint(20) NOT NULL,
`prvd_qty` int(11) NOT NULL,
`prvd_cost_price` double NOT NULL,
`prvd_selling_price` double NOT NULL,
`prvd_weight` double NOT NULL,
`prvd_tax` double NOT NULL,
`prvd_available_qty` double NOT NULL,
`prvd_usage_type_id` bigint(20) NOT NULL,
`prvd_threshold` double NOT NULL,
`prvd_expiry_date` date NOT NULL,
`prvd_prd_unit_id` bigint(20) NOT NULL,
PRIMARY KEY (`prvd_id`),
KEY `FK_product_vendor_details_product` (`prvd_prd_id`),
KEY `FK_product_vendor_details_vendor` (`prvd_vendor_id`),
CONSTRAINT `FK_product_vendor_details_product` FOREIGN KEY (`prvd_prd_id`) REFERENCES `product` (`prd_id`),
CONSTRAINT `FK_product_vendor_details_vendor` FOREIGN KEY (`prvd_vendor_id`) REFERENCES `vendor` (`ven_id`)
)
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Discussion of similar issue
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(It's not *directly* related, though, since they were using a composite key in the forum discussion you're referring to.)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic