外键约束失败 该怎么解决
WARNING]
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException:
Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (lgip
.tb_intention
, CONSTRAINT fk_intention_user
FOREIGN KEY (firm_id
) REFERENCES tb_user
(id
))
The error may involve com.nstc.lgip.idao.TbIntentionMapper.insert-Inline
The error occurred while setting parameters
SQL: insert into tb_intention (id, firm_id, industry_type ) values (?, ?, ? )
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (lgip
.tb_intention
, CONSTRAINT fk_intention_user
FOREIGN KEY (firm_id
) REFERENCES tb_user
(id
))
; SQL []; Cannot add or update a child row: a foreign key constraint fails (lgip
.tb_intention
, CONSTRAINT fk_intention_user
FOREIGN KEY (firm_id
) REFERENCES tb_user
(id
)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (lgip
.tb_intention
, CONSTRAINT fk_intention_user
FOREIGN KEY (firm_id
) REFERENCES tb_user
(id
))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你插入的 firm_id在tb_user表中没有对应的id。。。。。。。
外键表对主键表做左链接查询到有部分id没有在主键表中存在 之后是删是留改自己决定咯