首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

报错 no row with the given identifier exists: //could not load an entity

2012-11-04 
报错 no row with the given identifier exists: //could not load an entity:类似于:严重: No row with t

报错 no row with the given identifier exists: //could not load an entity:

类似于:

严重: No row with the given identifier exists: [com.twitter.entity.TwitterTopicImage#0]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.twitter.entity.TwitterTopicImage#0]org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [com.twitter.entity.TwitterTopicImage#0]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.twitter.entity.TwitterTopicImage#0]

?

是关联问题??也就是是说关系数据库一致性遭到了破坏,找到相关表,就可以解决了?? 比如说

有两张表,topic和topicImage.产生此问题的原因就是topic里做了关联<one-to-one>或者<many-to-one unique="true">(特殊的多对一映射,实际就是一对一)来关联topicImage.当hibernate查找的时候,topicImage里的数据没有与topic相匹配的,这样就会报No row with the given identifier exists这个错.(一句话,就是数据的问题!)

? ? ? 假如说,topic里有自身的主键id1,还有topicImage的主键id2,这两个字段.

? ? ? 如果hibenrate设置的单项关联,即使topic中的id2为null值,topicImage中id2中有值,查询都不会出错.但是如果topic中的id2字段有值,但是这个值在topicImage中主键值里并没有,就会报上面的错!

? ? ? 如果hibernate是双向关联,那么topic中的id2为null值,但是topicImage中如果有值,就会报这个错.这种情况目前的解决办法就是改成单项关联,或者把不对应的数据改对!

热点排行