`
woo_program
  • 浏览: 99543 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Hibernate:No row with the given identifier exists .

阅读更多

出现异常org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists

 

一.No row with the given identifier exists 解决方法

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

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

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

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

二.hibernate的一些常见的错误

No row with the given identifier exists

表示你现在查询的对象所关联的对象有问题,一般是因为数据的问题(该对象所关联的对象找不到)

Caused by: org.dom4j.DocumentException: Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence.
如果出现这行错误说明你的xml配置文件有不规范的字符,检查下。

net.sf.hibernate.MappingException: Error reading resource: hibernate/Hello_Bean.hbm.xml
如果出现这行错误说明你的hibernate的XML配置文件有错

net.sf.hibernate.MappingException: Resource: hibernate/Hello_Bean.hbm.xml not found
如果出现这行错误说明hibernate的XML配置文件没有找到,你应该把XML文件放在与你的类文件同个目录下,本文中是放在hibernateclasseshibernate目录下,也就是跟Hello_Bean.class类文件一起。

net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property name in class hibernate.Hello_Bean
如果出现这行错误说明你的xml文件里设置的字段名name的值与Hello_Bean.java类里的getXXX或setXXX方法不一致。

net.sf.hibernate.HibernateException: JDBC Driver class not found: org.gjt.mm.mysql.Driver
如果出现这行错误说明你的MYSQL驱动没有加进JB库里或者不在CLASSPATH里。
分享到:
评论

相关推荐

    no resource

    很抱歉,但根据提供的信息,标题"no resource"和描述"fe ge 2007 programe"没有明确指出任何具体的IT知识点。标签同样显示为"no resource",也没有提供额外的线索。压缩包子文件的文件名称列表包括:飞鸽传书升级...

    The Digital Object Identifier initiative: metadata implications

    数字对象标识符(Digital Object Identifier,简称DOI)是一种持久性标识符,用于唯一地标识数字资源,如学术文章、数据集等。DOI系统由国际DOI基金会管理,并在出版界广泛采用。随着数字资源的增加以及对资源描述的...

    apktool_AndResGuard:修复apktool打包出现No resource found...

    No resource found that matches the given name..... ....... 使用apktool-2.0.3也可以回编译,但是比如微信回编译后会增加到110M左右,很不友好。 而使用apktool-2.3.2和原包大小一样,65M左右。 基于apktool

    解决error C2065: '_beginthreadex' :undeclared identifier

    ### 解决Error C2065:'_beginthreadex':Undeclared Identifier #### 错误概述 在编译过程中遇到“Error C2065:'_beginthreadex':undeclared identifier”这一错误信息时,通常意味着编译器无法识别`_...

    PC-IDENTIFIER-09.03.03.00-01.04.00.03安装包-链接地址.txt

    标题和描述中提到的"PC-IDENTIFIER-**.**.**.**-**.**.**.**安装包-链接地址.txt"和"PC_IDENTIFIER_**.**.**.**_**.**.**.**安装包_链接地址"是文件的名称和描述,它们所指的知识点是关于一个特定版本的软件或插件的...

    Hibernate Tutorial 03 (Object Identifier).pdf

    在本教程中,我们将深入探讨Hibernate框架中的一个核心概念——对象标识符(Object Identifier)。通过本篇教程的学习,您将了解到对象标识符在Hibernate中的重要性以及如何正确地为持久化对象设置标识符。此外,我们...

    精心整理的ssh2 一些错误问题的记录(推荐)

    ### 错误七:No row with the given identifier exists 这意味着根据提供的标识符查询数据库时,没有找到任何行。检查SQL查询和标识符是否正确,以及数据库中是否存在预期的数据。 ### 错误八:No result defined ...

    hibernate.properties

    ## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager #hibernate.transaction.manager_lookup_class org.hibernate.transaction....

    PC-IDENTIFIER-09.01.00.00-01.17.00.15

    KB2558 Desigo CC 2.1 SR1, ABT-Pro, XWP: Lease time of S7DOS expired at 31.12.2015 https://support.industry.siemens.com/cs/us/en/view/109482349

    Manning.Java.Persistence.with.Hibernate.Nov.2006

    《Manning.Java.Persistence.with.Hibernate.Nov.2006》这本书主要聚焦于Java平台上的持久化技术,特别是使用Hibernate框架进行数据管理。Hibernate是一个开源的对象关系映射(ORM)框架,它允许开发者以面向对象的...

    硬件精灵Unknown Device Identifier 8.0.0.2606

    "硬件精灵Unknown Device Identifier 8.0.0.2606"是一款专门用于识别未知硬件设备的软件工具。在计算机领域,有时我们会遇到设备管理器中显示为“未知设备”的硬件,这通常是由于缺少相应的驱动程序或者系统无法正确...

    常用OID介绍说明

    OID,即Object Identifier,是网络管理中的一个关键概念,它是一种独特的数字序列,用于唯一地标识SNMP(简单网络管理协议)中的管理对象,如网络设备、服务或接口等。在IT领域,OID用于监控和管理系统性能,收集...

    hibernate错误解决方案

    ### Hibernate 错误解决方案 #### 一、概述 在使用Hibernate框架进行开发的过程中,经常会遇到各种各样的异常问题。这些问题可能会导致程序无法正常运行,甚至影响到系统的稳定性。本文将针对几个常见的Hibernate...

    ApkIDE3.3.0.0作者原版,解决常见apk打包安装问题.rar

    AndroidManifest.xml:1: error: No resource identifier found for attribute 'compileSdkVersionCodename' in package 'android' 解决方法:在AndroidManifest.xml中删除'compileSdkVersionCodename相关的。 二、...

    hibernate配置参数大全

    ### Hibernate配置参数详解 #### 一、数据库连接配置(JDBC) 在Hibernate中,与数据库交互的第一步就是正确地配置数据库连接。以下是一些关键的配置参数及其含义: 1. **`hibernate.connection.driver_class`**...

    [Go语言入门(含源码)] The Way to Go (with source code)

    The Way to Go,: A Thorough Introduction to the Go Programming Language 英文书籍,已Cross the wall,从Google获得书中源代码,分享一下。喜欢请购买正版。 目录如下: Contents Preface......................

    Hibernate Reference Documentation3.1

    1.2. Part 1 - The first Hibernate Application 1.2.1. The first class 1.2.2. The mapping file 1.2.3. Hibernate configuration 1.2.4. Building with Ant 1.2.5. Startup and helpers 1.2.6. Loading and ...

    PC-IDENTIFIER-09.03.03.00-01.04.00.03

    PC_IDENTIFIER_09.03.03.00_01.04.00.03.zip (140,6 MB)(SHA-256) Installing future versions of S7--PLCSIM Advanced (e.g. V5.0) will also correct this behavior. 官方链接(需要进口软件许可): ...

    hibernate常见异常

    a different object with the same identifier value was already associated with the session 是一种常见的异常,通常是由于在 Hibernate 中同一个 session 里面有了两个相同标识但是是不同实体所致。解决方案有...

    Python-KaggleInstacart市场篮子分析

    days_since_prior: days since the last order, capped at 30 (with NAs for order_number = 1) products (50k rows): product_id: product identifier product_name: name of the product aisle_id: foreign ...

Global site tag (gtag.js) - Google Analytics