关于:org.apache.ibatis.exceptions.PersistenceException:

今天执行删除的时候无论如何也删不掉

句子没问题什么都好好的

然后发现是因为有外键无法删除

解决办法就是删除外键或者使用连并删除语句

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`student`.`score`, CONSTRAINT `fk_score_student` FOREIGN KEY (`student_id`) REFERENCES `student` (`sid`))
### The error may exist in StudentMapper.xml
### The error may involve StudentMapper.delete-Inline
### The error occurred while setting parameters
### SQL: DELETE FROM student WHERE sid=?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`student`.`score`, CONSTRAINT `fk_score_student` FOREIGN KEY (`student_id`) REFERENCES `student` (`sid`))

foreign key constraint fails (student.score, CONSTRAINT fk_score_student FOREIGN KEY (student_id) REFERENCES student

猜你喜欢

转载自blog.csdn.net/m0_49194578/article/details/111825712