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)

at com.mysql.jdbc.Util.getInstance(Util.java:372)




发现:

mybatis 数据库表中外键关系存在时 useGeneratedKeys="true" keyProperty="id" 不能使用,需要删除表外键关系


0 0
原创粉丝点击