首页 > Web开发 > 详细

Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

时间:2016-04-05 15:41:45      阅读:325      评论:0      收藏:0      [点我收藏+]

报错信息:

org.hibernate.event.internal.DefaultLoadEventListener onLoad
INFO: HHH000327: Error performing load command : org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.weixin.db.model.Adminusers#15]

报错分析:

Hibernate的映射文件,表A里关联了表B的主键,当查询表A时,在B表里找不到对应记录时就会报错,如果只是逻辑删除不会报这种错误,只有当表B里测试没有id为15的这条数据了才会报错(已实际测试过);上面报错信息实体类后面【#15】表示实体类对应表id=15的记录找不到。也就是存在垃圾数据,可能是因为没有连带删除。

 

解决办法:

1. 修改配置文件加上 not-found="ignore" ”

即:

<many-to-one name="adminusers" class="com.weixin.db.model.Adminusers"
     fetch="select" lazy="false" not-found="ignore">

2. 要么就把垃圾数据从数据库删掉。

 

项目中遇到的问题,记录一下。

 

Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

原文:http://www.cnblogs.com/crazytrip/p/5355056.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!