今天用Hibernate建立外键的时候发现没有建立

但是创建了这个字段

情景:

user表有一字段role,role是role表id字段的外键

原因:

user表中已经有记录了,而且有的记录role这个字段在role表没有对应的id,所以就不能创建外键

解决方案:

先手动修改user.role字段,修改成已经在role表中存在的id值

ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint......的更多相关文章

  1. Error Code: 1452 Cannot add or update a child row: a foreign key constraint fails

    错误: Error Code: 1452 Cannot add or update a child row: a foreign key constraint fails 错误产生情景:我向一张带外键 ...

  2. Error 'Cannot add or update a child row: a foreign key constraint fails故障解决

    一大早的,某从库突然报出故障:SQL线程中断! 查看从库状态: mysql> show slave status\G Slave_IO_State: Waiting for master to ...

  3. MySQL:ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

    MySQL在删除一张表时出现 ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fa ...

  4. IntegrityError at /admin/users/userprofile/add/ (1452, 'Cannot add or update a child row: a foreign key constraint fails (`mxonline`.`django_admin_log`, CONSTRAINT `django_admin_log_user_id_c564eba6_

    报错现象 在执行 django 后台管理的时候添加数据导致 1452 错误 报错代码 IntegrityError at /admin/users/userprofile/add/ (1452, 'C ...

  5. ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails ()

    centos7.5 删除表空间文件失败 问题: mysql> alter table country discard tablespace; ERROR 1451 (23000): Cannot ...

  6. ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

    mysql 删除表时提示有外键 mysql> drop tables auth_group;ERROR 1217 (23000): Cannot delete or update a paren ...

  7. MySQL设置外键报错 #1452 - Cannot add or update a child row: a foreign key constraint fails 解决方法

    MySQL数据库,当我尝试在A表中设置B表的主键为外键时,报出错误:#1452 - Cannot add or update a child row: a foreign key constraint ...

  8. java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails

    HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.ConstraintV ...

  9. insert时报Cannot add or update a child row: a foreign key constraint fails (`yanchangzichan`.`productstatusrecord`, CONSTRAINT `p_cu` FOREIGN KEY (`cid`) REFERENCES `customer` (`cid`))错误

    mybatis在insert时报Cannot add or update a child row: a foreign key constraint fails (`yanchangzichan`.` ...

随机推荐

  1. base64:URL背景图片与web页面性能优化

    一.base64百科 Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,可用于在HTTP环境下传递较长的标识信息. 某人: 唉,我彻底废柴了,为何上面明明是中文,洒家却看不懂嘞,为什 ...

  2. android api sdk

    Platform Version API Level VERSION_CODE Notes Android 6.0 23 M API Changes Android 5.1 22 LOLLIPOP_M ...

  3. 【原创】Matlab.NET混合编程技巧之直接调用Matlab内置函数

                  本博客所有文章分类的总目录:[总目录]本博客博文总目录-实时更新    Matlab和C#混合编程文章目录 :[目录]Matlab和C#混合编程文章目录 在我的上一篇文章[ ...

  4. Cocos2d-x 3.2 学习笔记(十三)CocoStudio UI编辑器 by 保卫萝卜

    关于编辑器部分研究的不多,但基本能使用.最近时间不是很多,因此写blog的次数越来越少了.自从玩了<保卫萝卜>时候一直想要写一下,同时练下手感.基本的结构已经写的差不多了,主要完善写UI和 ...

  5. c#编码规范

    1  规范目的 --------------------- 3 2  适用范围 --------------------- 3 3  代码注释 --------------------- 3 3.1  ...

  6. SQLServer学习笔记系列8

    一.写在前面的话 最近一直在思考一个问题,什么才能让我们不显得浮躁,真正的静下心来,用心去感受,用心去回答每个人的问题,用心去帮助别人.现实的生活,往往让我们显得精疲力尽,然后我们仔细想过没用,其实支 ...

  7. Java中不同的并发实现的性能比较

    Fork/Join框架在不同配置下的表现如何? 正如即将上映的星球大战那样,Java 8的并行流也是毁誉参半.并行流(Parallel Stream)的语法糖就像预告片里的新型光剑一样令人兴奋不已.现 ...

  8. ssl证书生成:cer&jks文件生成摘录

    一.生成.jks文件 1.keystore的生成: 分阶段生成:     keytool -genkey -alias yushan(别名) -keypass yushan(别名密码) -keyalg ...

  9. 【Swift学习】Swift编程之旅---字符与字符串(五)

    String是swift的字符串类型.一个字符串是一个有效的字符序列,因此还可以使字符集合表示.通过+符号可以连接字符串. String 类型是一种快速.现代化的字符串实现.每一个字符串都是由独立编码 ...

  10. 提取KIndle中每本书的笔记并单独保存

    整体思路 目标:将Kindle中的每本书的笔记标注单独提取出保存为一个Markdown文件 其中检测KIndle是否已经正常插入的判断方法: 思路1:读取媒介挂载记录 思路2:直接判断挂载地址是否存在 ...