insert时报Cannot add or update a child row: a foreign key constraint fails (`yanchangzichan`.`productstatusrecord`, CONSTRAINT `p_cu` FOREIGN KEY (`cid`) REFERENCES `customer` (`cid`))错误

mybatis在insert时报Cannot add or update a child row: a foreign key constraint fails (`yanchangzichan`.`productstatusrecord`, CONSTRAINT `p_cu` FOREIGN KEY (`cid`) REFERENCES `customer` (`cid`))错误,重点在“a foreign key constraint fails”,说明主表和附表有外键关联,无法插入为空的值。解决方案:1):取消表的外键 ,2)插入值不能有空值

上一篇:Error 'Cannot add or update a child row: a foreign key constraint fails故障解决


下一篇:hibernate4一对多关联多方多写一次外键导致无法创建java.lang.NullPointerException以及Cannot add or update a child row: a foreign key constraint fails