`

Hibernate:no row with the given identifier exists

    博客分类:
  • J2EE
阅读更多

ObjectNotFoundException: no row with the given identifier exists

Where it can occur:

This might occur if you try to load a non-proxied object with session.load() or you load a proxied object and later access the proxy. It may also occur when loading mapped collections which are not eagerly fetched.

What it means:

This means just what it says - Hibernate expected to have a row with a certain id in the database, and did however not find it.

How it can be caused:

Wrong id for load

If you are using a nonexistant id for a load(), you will get this exception. Note that if you are using proxies, this may occur later on, when the proxy is first "broken".

Broken foreign key relationships

If you map for example a many-to-one relationship, and the table containing the objects on the "many" side contains a foreign key to a non-existant row of the "one" side table, you will get such an exception. This will only happen if the collection is not fetched eagerly.

Reusing a session across multiple transactions

The hibernate session internally memorizes some state. For example it internally stores ids which it assumes are already deleted from the database. So if you make the session believe somehow an object with a certain id has been deleted, and later try to load it again, you will get this exception without Hibernate even trying to access the database. So be careful with that.

How it can be fixed:

  • Check the ids you are using for load
  • Validate your foreign key relationships - the database should already maintain such integrity constraints.
  • Beware of multiple transactions within a single session. Try to stick to "one session, one transaction" rule. Especially do not reuse sessions after an HibernateException.
分享到:
评论

相关推荐

    no resource

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

    解决error C2065: '_beginthreadex' :undeclared identifier

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

    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

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

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

    The Digital Object Identifier initiative: metadata implications

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

    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 ...

    hibernate错误汇总

    错误八:Exception in thread "main" org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: org.model.User 错误原因:这个错误表示在尝试获取主键为1的实体...

    将tc下的程序移植到vc中.pdf

    8. **错误提示:error C2065: 'EGA' : undeclared identifier 或 error C2065: 'EGAHI' : undeclared identifier** 解决办法:删除定义`int gdriver = EGA, gmode = EGAHI;`的代码,改用`initgraph(640, 480);`初始...

    hibernate常见异常

    、org.hibernate.id.IdentifierGenerationException 以及 a different object with the same identifier value was already associated with the session 等。 1. net.sf.hibernate.MappingException ...

    4.2.2 variables_to_restore函数的使用样例.ipynb

    TensorFlow资源以及具体的用法

    Oracle数据库表名支持的最大长度是多少

    本文介绍Oralce数据库中,表名可以使用的最大长度。这个长度也是Oracle...*Cause: An identifier with more than 30 characters was specified. *Action: Specify at most 30 characters. 从这个错误提示可以看出

    Keil MDK 编译 ucOS-II 出现的警告和错误解决

    错误:L6238E:os_cpu_a.o(subr) contains invalid call from '~PRES8 (The user did not require code to preserve 8-byte aligment of 8-byte data objects)' function to 'REQ8 (Codewas permitted to depend on ...

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

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

    developing android application with adobe air.part3.rar

    Chapter 1 : AIR Installing the Adobe Development Tools Installing the AIR Runtime on an Android Device What Is in the AIR SDK New ActionScript Libraries AIR on the Desktop Versus AIR on Android Mobile...

    Hibernate 参数配置详解

    ### Hibernate 参数配置详解 #### 一、概述 Hibernate 是一款流行的 Java 持久层框架,它通过提供一套丰富的 API 和配置选项来简化数据库访问。本文档将深入探讨 Hibernate 的核心配置参数及其功能,帮助开发者更...

    hibernate错误解决方案

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

    Hibernate Tutorial 03 (Object Identifier).pdf

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

    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....

    hibernate常见问题及处理.doc

    5. `a different object with the same identifier value was already associated with the session` 这个异常表明在同一个Hibernate Session中存在两个具有相同标识但实际是不同对象的情况。处理方法有: - 使用`...

    hibernate配置参数大全

    12. **`hibernate.use_identifier_rollback`**:决定在删除操作中是否使用标识符回滚。 - 示例: ```properties hibernate.use_identifier_rollback=true ``` 13. **`hibernate.use_sql_comments`**:决定...

Global site tag (gtag.js) - Google Analytics