Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.xxx.xx.model.info.News#15]

场景分析:

主表:新闻表(news),从表:新闻评论表(newsComment)(含有newsId),系统在删除新闻的时候,没有将从表中的该新闻关联的评论删除的话,程序在加载新闻评论列表页时,通过Hibernate延迟加载newsComment.news对象,发现无法找到,所以报如上异常信息。

解决:在service中事务管理,首先依据newsId查询评论表中记录,先删除评论,后删除新闻。完成数据库数据完整性。

posted @ 2013-03-28 13:50  全新时代-小小程序员大梦想  阅读(241)  评论(0编辑  收藏  举报