No %s entity with id %s exists! Spring JPA 删除(delete) 报错
来源:互联网 发布:佳能1880清零软件 编辑:程序博客网 时间:2024/06/05 03:25
今天遇到一个异常,很奇怪。
Exception的message是:No [this is your entity information] entity with id [this is id] exists!
在使用Spring的JPA的时候,删除操作可能会报出这个异常:
"exception": "org.springframework.dao.EmptyResultDataAccessException",
"message": "No class com.xxx.yyy.zzz entity with id 123 exists!",
这个异常是从org.springframework.data.jpa.repository.support.SimpleJpaRepository中抛出的。原因是根据id删除一条记录的时候,该记录已经不存在了。在数据库中直接使用delete语句去删除数据的时候,如果符合where子句条件的记录不存在则不会发生什么,只是告诉用户0行被删除。
但是在JPA中,看了下源码,会先根据条件id去查询,如果查询不到数据就会抛出这个异常。
ps:这个异常可能会在其他地方抛出,message内容也可能有所不同,这里只是说一下我遇到的情况。
0 0
- No %s entity with id %s exists! Spring JPA 删除(delete) 报错
- springboot-jpa报错No identifier specified for entity:
- no row with the given identifier exists报错
- 关于Arcmap发布地图报错:No transformation exists from the data fram's datum to WGS1984 Major Auxiliary Sphere
- spring data jpa @Query注解中delete语句报错
- spring-data-jpa @Query注解中delete语句报错
- activiti报错:no deployed process definition found with id
- org.activiti.engine.ActivitiObjectNotFoundException: no deployed process definition found with id 's
- spring jpa报错
- spring jpa报错
- 关于使用Hibernate出现报错No row with the given identifier exists:
- 关于Hibernate:No row with the given identifier exists报错的解决办法
- # s: attempt to create saveOrUpdate event with null entity
- spring boot 的 JPA 操作,提示Entity过时,No identifier specified for entity
- spring data jpa @Query注解中delete语句报错 : @Modifying注解的使用
- No row with the given identifier exists: [OfficeWH.entity.RoleRight#101]
- No row with the given identifier exists: [com.wanmei.entity.TableMeta#3219]
- No row with the given identifier exists: [com.device.entity.DcDevice]异常处理
- my代码跟踪之driver_register
- OC 第一个OC类
- cookies的用法
- 强大的Spring缓存技术(下)
- 打造平台
- No %s entity with id %s exists! Spring JPA 删除(delete) 报错
- bootstrap/angularjs 日期控件
- How-To set up a serial console on Debian
- SSM框架——使用MyBatis Generator自动创建代码
- android webview与H5混合开发,webview自定义缓存
- 加速HTML5应用的几大方法
- java中使用事务控制循环更新插入数据与sqlMap中使用iterate循环union all效率比较
- Maven 5.Maven生命周期
- SAP中RFC与BAPI