【发布时间】:2014-06-26 08:19:00
【问题描述】:
嗨,我在 mysql 中为 spring hibernate 中的 onetoone 映射创建了两个表,但我收到错误 ERROR 1215 (HY000): Cannot add foreign key constraint
这是我的第一张桌子
CREATE TABLE `Employee` ( `empId` int(11) NOT NULL,
`empName` varchar(255) DEFAULT NULL, `empExp` int(11) NOT NULL,
`empTeam` varchar(255) DEFAULT NULL, `teamId` int(11) DEFAULT NULL);
第二张桌子
CREATE TABLE `EmpTeam` ( `teamId` int(11) NOT NULL,
`teamName` varchar(255) DEFAULT NULL, PRIMARY KEY (`teamId`) ,
KEY `FK1` (`teamId`), CONSTRAINT `FK1` FOREIGN KEY (`teamId`)
REFERENCES `Employee` (`empId`));
请帮忙,提前谢谢
【问题讨论】:
-
获取详细错误:运行
SHOW ENGINE INNODB STATUS并查看“最新外键错误”部分
标签: mysql spring hibernate-annotations