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 ...
随机推荐
- sqlserver-4064
早上忘记了SQLServer的sa帐户密码,在网上搜索才弄清楚了解决办法:1.在SQLServer企业管理器中输入以下命令:ALTER LOGIN sa ENABLE GO ALTER LOGIN s ...
- 几个简单的例子让你读懂什么是JAVA的堆栈跟踪
简单的来说,堆栈跟踪就是我们的程序在抛出异常时使用的方法调用列表. 简单的例子 通过问题中给出的示例,我们可以准确地确定应用程序中抛出异常的位置. 我们来看看堆栈跟踪: Exception in ...
- 一个基于JRTPLIB的轻量级RTSP客户端(myRTSPClient)——收流篇:(四)example代码解析
一.example逻辑伪码 myRTSPClient附带3个example程序:simple_example.complete_example.common_example.后两个example都是从 ...
- install ubuntu16.04
1.添加分区 添加驱动目录/boot,ext4文件系统 ,给200m够了,图中2G多了,勾选格式化 添加 根目录/ 25G ,ext4文件系统,勾选格式化 添加 家目录 /home ,30G ...
- vue-cli脚手架npm相关文件解读(4)utils.js
系列文章传送门: 1.build/webpack.base.conf.js 2.build/webpack.prod.conf.js 3.build/webpack.dev.conf.js 4.bui ...
- Thread.interrupt()方法理解
原博客地址: 多线程编程 实战篇 (四) 不客气地说,至少有一半人认为,线程的"中断"就是让线程停止. 如果你也这么认为,那你对多线程编程还没有入门. 在java中,线程的中断(i ...
- 关于 Go 中 Map 类型和 Slice 类型的传递
关于 Go 中 Map 类型和 Slice 类型的传递 Map 类型 先看例子 m1: func main() { m := make(map[int]int) mdMap(m) fmt.Printl ...
- Spring-MVC开发步骤(入门配置)
Spring-MVC开发步骤(入门配置) Step1.导包 spring-webmvc Step2.添加spring配置文件 Step3.配置DispatcherServlet 在web.xml中: ...
- Oracle:解锁scott用户及设置密码
关于Oracle 10g scott用户解锁的方法两则 解决方法一. 首先确认已经安装oracle 数据库和客户端 在客户端DOS下执行如下语句: 注意提示符号 c:\sqlplus /nolog s ...
- ios 初体验< UISegmentedControl 分段控件>
小知识: 数组快速创建 @[@"",@"",@"",@"".......],字典快速创建方法:@{@"&q ...