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">
            <column name="domain"  not-null="true" />
    </many-to-one>

2,查询的列的值在外键表中查不到!例如学生表引用的课程在课程表中根本就没有!

时间: 2024-08-09 12:11:48

No row with the given identifier exists-----hiberbate非主键关联的相关文章

(转)收集: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[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这个错.(一句话,就是数据的

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

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

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的映射

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="

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

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

关于Hibernate级联更新插入信息时提示主键不为空的问题“org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1 ”

org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1 出现这一错误的主要原因有两个       使用的是hibernate的saveOrUpdate方法保存实例.saveOrUpdate方法要求ID为null时才执行SAVE,在其它情况下执行UPDATE.在保存实例的时候是新增,但你的ID不为null,