今天用Hibernate建立外键的时候发现没有建立
但是创建了这个字段
情景:
user表有一字段role,role是role表id字段的外键
原因:
user表中已经有记录了,而且有的记录role这个字段在role表没有对应的id,所以就不能创建外键
解决方案:
先手动修改user.role字段,修改成已经在role表中存在的id值
<script type="text/javascript">
$(function () {
$('pre.prettyprint code').each(function () {
var lines = $(this).text().split('\n').length;
var $numbering = $('<ul/>').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($('<li/>').text(i));
};
$numbering.fadeIn(1700);
});
});
</script>
分享到:
相关推荐
(1452, 'Cannot add or update a child row: a foreign key constraint fails (`mxonline`.`django_admin_log`, CONSTRAINT `django_admin_log_user_id_c564eba6_fk_auth_user_id` FOREIGN KEY (`user_id`) ...
这篇文章主要涉及到在数据创建表时,遇到ERROR 1215 (HY000): Cannot add foreign key constraint 问题方面的内容,对于在数据创建表时,遇到同样问题感兴趣的同学可以参考一下。 一、问题的提出 创建两个表: ...
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails 这是因为你尝试删除的表中的字段被用作了其他表的外键,因此在删除这个表(父表)之前必须先删除具有外键的表(子表)...
在SSM项目中执行一个删除用户操作时报错,遂在navicat中尝试是否可以直接删除,报如下所示错误 student表的主键是selectedcourse表的外键,当需要删除student表内的一行数据时,必须在selectedcourse表内设置该外键...
Failed to resolve: com.android.support.constraint:constraint-layout:1.0.0-alpha1
Error Correction Coding - Mathematical Methods and Algorithms (Source Files Contained).pdf Error Correction Coding Mathematical Methods and Algorithms Todd K. Moon Utah State University @ E ! C I E N...
"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'a3b6420a-6724-11ea-b2a3-d773d1d6999f' for key 'callId'\nThe SQL being executed was: INSERT INTO `ly_call` (`call_id`, `mobile`, ...
Cannot delete or update a parent row: a foreign key constraint fails (...) 这可能是MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据。可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况。 SET ...
A beautiful gift Cards for android Inspiration comes from dribbble Preview Requirements Use Android Studio 2.2 Preview 5 or higher, as the following are not available in earlier versions: ...
A deletion operation will _____ if the deletion leads to the violation of a referential integrity constraint. (a) fail (b) succeed with warning (c) succeed without warning (d) crash the ...
Ruby Quick Syntax Reference.pdf Ruby速查手册,Ruby这语言听起来就很酷! 英文PDF版本,欢迎下载!
Each index row in node pages contains an index key (or set of keys for a composite index) and a pointer to a page at the next level for which the first key value is the same as the key value in the ...
添加级联操作 语法:ALTER TABLE 表名 ADD CONSTRAINT 外键名称 FOREIGN KEY (外键字段名称) REFERENCES 主表名称(主表列名称) ON UPDATE CASCADE ON DELETE CASCADE ; 2. 分类: 1. 级联更新:ON UPDATE CASCADE 2...
Key Concepts...........................................................................................................16 Further Reading..................................................................
4.1.3 Kalman filter with a linear advection equation . . . . . . . . 29 4.2 Nonlinear dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.2.1 Extended Kalman ...
As such, while it cannot be fully understood in the restricted field of computer science, it is not necessarily the search of clever emulations of human cognition. While digging into the secrets of ...
16 Steps to Develop and Implement a Software Quality Assurance Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Step 1. Document the Plan. . . ...
constraint 外键名 foreign key(字段) references 主表(字段) on delete 级联动作 on update 级联动作 3、级联动作 1、cascade :删除、更新同步(被参考字段) 2、restrict :不让主表更新、删除 3、set null...
For example, suppose a transaction scanned a page using an S lock and then subsequently decided to perform a row level update. The row would obtain an X lock, but now the page would require an IX ...