org.hibernate.ObjectNotFoundException: No row with the given identifier exists

    维护老系统时出现的问题,出现的原因我简述一下:

         table1与table2是关联表,T1中有T2的主键 "T1_id",当T1中的 "T2_id" 不为null时,而T2中的"T2_id"为空,那么就会报上面这个错。

         反之T1的"T2_id"为null,而T2中的"T2_id"不为null,没有任何影响。

         所以这个错误是由于数据不匹配出现的。

    解决方案:

        1.在映射文件里加上 not-found="ignore" ,这个方法我是百度到的,按道理是没问题的,但是没有生效,可以一试

        

        

        2.根据console中给出的信息,去排查相关表的主外键信息是否有问题。

         比如我的console中是 :org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.fpscc.model.UserAuthInfo#409]

         我去数据库中查了下,User_Auth_Info_id中没有 409 这一条数据,而另外一个和它有关联的表中的"User_Auth_Info_id"是有 409 这一条数据的,

         所以我稍微改动了下,就正常了。

时间: 2024-08-05 03:19:10

org.hibernate.ObjectNotFoundException: No row with the given identifier exists的相关文章

Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

报错信息: org.hibernate.event.internal.DefaultLoadEventListener onLoad INFO: HHH000327: Error performing load command : org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.weixin.db.model.Adminusers#15] 报错分析: Hibernate的映射

Hibernate异常No row with the given identifier exists

package com.prms.urms.entity; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.En

hibernate出现No row with the given identifier exists问题

产生此问题的原因: 有两张表,table1和table2.产生此问题的原因就是table1里做了关联<one-to-one>或者<many-to-one>来关联table2.当hibernate查找的时候,table2里的数据没有与table1相匹配的,这样就会报No row with the given identifierexists这个错. 解决方法: 1.修改数据使关联字段能查询到数据 2.在<many-to-one>中设置not-found="ign

(转)收集:Hibernate中常见问题 No row with the given identifier exists问题的原因及解决

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

No row with the given identifier exists

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

No row with the given identifier exists[ArtProject.Domains.Users#2]

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

Hibernate3.x异常No row with the given identifier exists 解决方法

这个异常是在 多对一关系映射时,一方表中对应的数据不存在才抛出的.原来的配置: <many-to-one class="com.art.model.user.UserInfo" fetch="join" name="userInfo" > <column name="userId" unique="true"/> </many-to-one> 修改后的: <many

No row with the given identifier exists-----hiberbate非主键关联

这个错误有两种情况: 1,非主键关联为配置property-ref=(关联表的非主键列) 属性! Hibernate配置文件中关联默认的是主键关联,如果要关联非主键则必须加property-ref 属性 <many-to-one name="domainBO" class="***.common.model.bo.DomainBO" fetch="select" property-ref="domain">    

hibernate延迟加载(get和load的区别)(转)

在hibernate中我们知道如果要从数据库中得到一个对象,通常有两种方式,一种是通过session.get()方法,另一种就是通过session.load()方法,然后其实这两种方法在获得一个实体对象时是有区别的,在查询性能上两者是不同的. 一.load加载方式 当使用load方法来得到一个对象时,此时hibernate会使用延迟加载的机制来加载这个对象,即:当我们使用session.load()方法来加载一个对象时,此时并不会发出sql语句,当前得到的这个对象其实是一个代理对象,这个代理对象