mybatis 数据库表中外键关系存在时 useGeneratedKeys="true" keyProperty="id"
来源:互联网 发布:怎么能订阅知乎周刊 编辑:程序博客网 时间:2024/04/29 07:21
五月 20, 2016 2:07:00 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [mockPlatform] in context with path [/MockPlatform] threw exception [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 (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))
### The error may involve com.cmcc.mockpf.mybatis.mapper.RoundResultMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: insert into t_round_result ( project_id, rount_count, success_count, fail_count ) values ( ?, ?, ?, ? )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))
; SQL []; Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:389)
严重: Servlet.service() for servlet [mockPlatform] in context with path [/MockPlatform] threw exception [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 (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))
### The error may involve com.cmcc.mockpf.mybatis.mapper.RoundResultMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: insert into t_round_result ( project_id, rount_count, success_count, fail_count ) values ( ?, ?, ?, ? )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))
; SQL []; Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mockplatform`.`t_round_result`, CONSTRAINT `FK_Reference_3` FOREIGN KEY (`project_id`) REFERENCES `t_case_info` (`id`))
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:389)
at com.mysql.jdbc.Util.getInstance(Util.java:372)
发现:
mybatis 数据库表中外键关系存在时 useGeneratedKeys="true" keyProperty="id" 不能使用,需要删除表外键关系
0 0
- mybatis 数据库表中外键关系存在时 useGeneratedKeys="true" keyProperty="id"
- mybatis useGeneratedKeys = "true"
- mybatis 中哪些数据库支持 useGeneratedKeys="true"
- mybatis 中哪些数据库支持 useGeneratedKeys="true"
- Mybatis插入语句useGeneratedKeys="true"的用法
- mybatis新增时返回主键id,useGeneratedKeys的用法
- 数据库中外键知识
- mybatis keyproperty 总是返回1
- Insight mybatis insert useGeneratedKeys
- Mybatis 配置文件 useGeneratedKeys 参数
- Mybatis利用useGeneratedKeys返回最新插入记录的id Parameter 'id' not found. Available
- Mybatis+mysql+allowMultiQueries=true
- 父子关系inverse=true
- 数据库中外键的作用
- mybatis 大坑之 useGeneratedKeys 返回值不是id,而是0跟1
- inverse="true" 放弃维护关联关系=true
- Mybatis 配置 lazyLoadingEnabled=true 的错误
- 数据库中外键属性的设置
- 常用有用快捷键
- Java中的异常
- REDIS集群
- 关于HttpClient的总结
- 【leetcode】12. Integer to Roman
- mybatis 数据库表中外键关系存在时 useGeneratedKeys="true" keyProperty="id"
- MVC,MVP 和 MVVM 的图示
- K3WISEV12.2百度盘安装包及破解补丁及授权文件
- activity launchMode
- 图像 熵
- 【bzoj3343】教主的魔法
- JAVA SE 8 学习笔记(五)并发增强
- IntelliJ IDEA 12创建Maven管理的Java Web项目(图解)
- NioEventLoop源码