zoukankan      html  css  js  c++  java
  • 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#4]

    报错分析:

      Hibernate的映射文件,表A里关联了表B的主键,当查询表A时,在B表里找不到对应记录时就会报错,如果只是逻辑删除不会报这种错误,只有当表B里测试没有id为4的这条数据了才会报错(已实际测试过);上面报错信息实体类后面【#4】表示实体类对应表id=4的记录找不到。也就是存在垃圾数据,可能是因为没有连带删除。

    解决办法:

      第一种:

        修改配置文件加上 not-found="ignore" ”

        即:

    <many-to-one name="powermethod" class="com.java.model.BaseFThermalPowerMethod"
         fetch="select" lazy="false" not-found="ignore">

      第二种:

        在B表中新增id=4的行数据

  • 相关阅读:
    前端工程师须知pc电脑端分辨率
    移动前端的坑
    07.01工作笔记
    缓存
    word-wrap,white-space和text-overflow属性
    页面结构
    Spring Bean的作用域和自动装配
    Spring配置文件
    初识Spring和IOC理解
    MyBatis缓存
  • 原文地址:https://www.cnblogs.com/wqk66/p/11394804.html
Copyright © 2011-2022 走看看