Could not execute JDBC batch update; SQL [delete from role where roleId=?]; constraint [null]; neste
今天在写多个删除功能的时候出现了这么一个错误:意思是删除操作的时候,没有找到对应的外键。
Cannot delete or update a parent row: a foreign key constraint fails (`ssh03`.`role_privilege`, CONSTRAINT `FK45FBD628F05C38CB` FOREIGN KEY (`role_id`) REFERENCES `role` (`roleId`))
Cannot delete or update a parent row: a foreign key constraint fails (`ssh03`.`role_privilege`, CONSTRAINT `FK45FBD628F05C38CB` FOREIGN KEY (`role_id`) REFERENCES `role` (`roleId`))
Could not execute JDBC batch update
Could not execute JDBC batch update; SQL [delete from role where roleId=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [delete from role where roleId=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
在网上找了很久,都没有找到对应的错误。。我的删除操作是先查找Role对象,再通过删除它。
后来debug起来又是匪夷所思的:后台能够得到外界传递过来的id
在查询对象的时候,就死活查不了外键的数据【让我搞了很久很久】。。
最后发现id上多了一个空格???????至于为什么多了一个空格,,我现在还不知道。。。于是把空格去掉,就解决这个bug了。。。
/*批量删除*/
public String deleteSelect() {
for (String s : selectedRow) {
roleServiceImpl.delete(s.trim());
}
return "list";
}
….如果知道为什么会多出一个空格的,请在评论下告诉我….
Could not execute JDBC batch update; SQL [delete from role where roleId=?]; constraint [null]; neste的更多相关文章
- 严重: Could not synchronize database state with session org.hibernate.exception.DataException: Could not execute JDBC batch update
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #ff2600 } p.p2 { margin: 0.0px 0 ...
- hibernate 级联删除报更新失败的问题(org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update)
首先hibernate级联删除的前提是,首先需要在映射文件中配置,配置多表之间的关联关系: 下面以部门表(Dept)和员工表(Emp)为例: 1.在Emp.hbm.xml映射文件中配置many-to- ...
- Hibernate 抛出的 Could not execute JDBC batch update
异常堆栈 org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at or ...
- exception is org.hibernate.exception.DataException: Could not execute JDBC batch update at
没有什么问题,但是却报了Could not execute JDBC batch update的错,主要是配置文件设置了关联,数据却没有关联造成的,只要数据正确就没有问题. 另外,造成这个原因的还可能 ...
- Hibernate错误:Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
报错:Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execu ...
- hibernate的Could not execute JDBC batch update错误原因及处理
http://blog.csdn.net/derpvailzhangfan/article/details/2332795\ 上述问题: 一设置关联 二包含关键字 三 映射文件设置 catalog=“ ...
- hibernate添加数据报错:Could not execute JDBC batch update
报错如下图所示: 报错原因:在配置文件或注解里设置了字段关联,但数据却没有关联. 解决方法:我的错误是向一个多对多的关联表里插入数据,由于表中一个字段的数据是从另一张表里get到的,通过调试发现,从以 ...
- 【转】表删除时 Cannot delete or update a parent row: a foreign key constraint fails 异常处理
转载地址:http://lijiejava.iteye.com/blog/790478 有两张表,结构如下: t_item: t_bid: id ...
- 表删除时 Cannot delete or update a parent row: a foreign key constraint fails 异常处理
有两张表,结构如下: t_item: t_bid: id int id int n ...
随机推荐
- 压缩感知中的数学知识:稀疏、范数、符号arg min
转自:http://blog.csdn.net/jbb0523/article/details/40262629 1.稀疏:什么是K稀疏呢? 在压缩感知里经常提到 "K稀疏" 的概 ...
- angularjs select标签中参数的传递
今天做的一个demo中需要一个下拉选择框,并根据所选择的内容向服务器发送请求. 首先百度了一下angularjs关于select的使用,一种采用ng-repeat的方式. <select ng- ...
- Integer陷阱(0~127和其他 数值相等对象比较)
Integer 类在对象中包装了一个基本类型 int 的值. 有一个陷阱存在,经常出现在面试题中,情况如下面代码 public class IntegerDemo { public static vo ...
- Tomcat7安装及配置教程
Apache Tomcat7.0安装及配置教程.. Apache Tomcat7.0官方网站链接:http://tomcat.apache.org/ apache-tomcat-7.0.73-wi ...
- sp1是什么意思
sp1是什么意思... ----------------------------- ------------------------------ 一.补丁包 SP = service pack ,补丁 ...
- APUE 3 -- 信号(signal)<I> :概念
信号可以理解成一种软件中断.他提供了一种异步处理事件的方式.每个信号都有一个与之对应的信号名,这些信号名都带有SIG前缀,如:SIGABRT,SIGALARM.头文件signal.h 中定义了所有的信 ...
- Andrew Ng机器学习课程笔记--week4(神经网络)
Neural Networks: Representation 一. 内容概要 Neural Network Model Representation 1 Model Representation 2 ...
- 【渗透课程】第一篇-Web渗透需要接触的语言
---恢复内容开始--- 上一篇我们讲过了,Web渗透的基本原理,在原理中我们也提到了Web应用程序(脚本语言),本章就谈到了Web渗透要涉及的语言. 涉及语言: 1.html:是前段语言的其中一个, ...
- layer 弹出在 iframe内部弹出不居中是原因
parent.layer..confirm('您确定要删除这个模型吗?',{ shade: false, fixed: false, btn: ['确定', '取消'] //按钮 }, functio ...
- ionic实战系列(一):ionic的开发环境配置和编译、发布
我的ionic实战系列是基于<<Ionic实战>>[美]Jeremy Wilken著-这本书的读书笔记,有诸多借鉴,不详细的地方请参考书籍本身的内容. 1.1技术栈模型 Ion ...