项目其中一个功能用不了报错
报错代码
org.springframework.dao.DataIntegrityViolationException:
studentmanager/s_course
, CONSTRAINT course_teacher_foreign
FOREIGN KEY (teacher_id
) REFERENCES s_teacher
(id
))studentmanager/s_course
, CONSTRAINT course_teacher_foreign
FOREIGN KEY (teacher_id
) REFERENCES s_teacher
(id
)); ]; Cannot delete or update a parent row: a foreign key constraint fails (studentmanager/s_course
, CONSTRAINT course_teacher_foreign
FOREIGN KEY (teacher_id
) REFERENCES s_teacher
(id
)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (studentmanager/s_course
, CONSTRAINT course_teacher_foreign
FOREIGN KEY (teacher_id
) REFERENCES s_teacher
(id
))
我的建议是把你表中的外键删除掉。
阿里规约中不允许使用外键,会存在各种各样的问题
数据库主外键冲突,你不能删除在别的表中有外键的主键数据。你也不能更新主键。
大概意思就是。
比如你有个user表,主键id,另一张表比如信息表其中引用了user表的主键作为外键,这个时候,你不能更新或者删除user表的主键,因为这会破坏主外键约束。
teacher_id
这个是你错误的字段