Hibernate:No row with the given identifier exists
问题描述:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists
问题原因:数据错误!
先说下两张表的关联关系:
表A
表B
列名 A1(PK) A2(FK)=B1 A3
列名 B1(PK) B2 B3
如果在TestB中新增一条数据,其中B2=9,而TestA表中不存在A1=9的数据,那么在使用Hibernate对象关联查询时,就会出现上面的错误!
解决方法:
删除TestB表中新增的数据或者在TestA表中增加对应的数据,即可。
Courtesy costs nothing. 彬彬有礼,惠而不费 。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步