需要技术交流加群:939196547

需要技术交流加群:939196547

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [实体类名]

在开发的时候用hibernate框架对两个实体建立了many-one的关系,通过id来查询数据不能查出来还报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [实体类名]

原因是建立关系的外键有空值,而且没有对映射文件中many-to-one设置not-found="ignore"导致,当然还有一种等效的注解方式,

在实体类的中的外键上添上 @NotFound(action=NotFoundAction.IGNORE)
posted @ 2018-10-24 14:39  不要浪  阅读(112)  评论(0编辑  收藏  举报

需要技术交流加群:939196547