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. 彬彬有礼,惠而不费 。
原文地址:https://www.cnblogs.com/maso1987/p/2876835.html