Maison  >  Questions et réponses  >  le corps du texte

java - 外键约束失败 该怎么解决

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))

PHP中文网PHP中文网2741 Il y a quelques jours536

répondre à tous(2)je répondrai

  • 高洛峰

    高洛峰2017-04-18 10:22:27

    Le firm_id que vous avez inséré n'a pas d'identifiant correspondant dans la table tb_user. . . . . . .

    répondre
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:22:27

    La table de clé étrangère effectue une requête de lien gauche sur la table de clé primaire et constate que certains identifiants n'existent pas dans la table de clé primaire. Vous pouvez alors décider de les supprimer ou de les conserver

    .

    répondre
    0
  • Annulerrépondre