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

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

阅读更多

1、问题说明

hibenate中实体关联映射中<many-to-one>中如:

<many-to-one name="farmerMarket" column="FARMERMARKETID" class="org.mcp.ep.entity.Farmermarket"></many-to-one>

 

如果farmerMarket对象,在本表中不存在,那么查询的时候会报错,提示找不到该外键值的列,也就是说以该外键对主键的对象在表中不存在。因此该外键不能赋值。

 

 

2、解决方法

 

在赋值时,设置farmerMarket对象(外键所引用对象)为null,让所引对象为空,而不是让其不存在.

分享到:
评论

相关推荐

    Hibernate中get和load方法的区别以及close(),clear()、evict()等的区别

    Hibernate Session中的 flush方法的作用 ...load方式检索不到的话会抛出org.hibernate.ObjectNotFoundException异常 get方法检索不到的话会返回null 2.从检索执行机制上对比: get方法和find方法都是直接从数据库中检索

    jdbc基础和参考

    3.hibernate的配置文件(hibernate.cfg.xml)得存在 4.POJO.hbm.xml文件存在 5.hibernate的jar包以及数据库的驱动包存在 Hibernate的编程: 1.构建Configuration对象读取配置文件 2.读取映射文件 3.构建SessionFactory...

    hibernate操作数据库笔记

    //该方法将到classpath下解析hibernate.cfg.xml中的配置,如果不用Hibernate默认的配置文件名和路径,可在该方法中指定Hibernate配置文件的名称和路径 2.用Configuration对象获取SessionFactory和Session对象:...

    java的ejb.jar包

    javax.ejb.ObjectNotFoundException.class javax.ejb.RemoveException.class javax.ejb.SessionBean.class javax.ejb.SessionContext.class javax.ejb.SessionSynchronization.class javax.ejb.TimedObject.class ...

    javax.ejb.rar

    javax.ejb.ObjectNotFoundException.class javax.ejb.PostActivate.class javax.ejb.PrePassivate.class javax.ejb.Remote.class javax.ejb.RemoteHome.class javax.ejb.Remove.class javax.ejb.RemoveException....

    javax.ejb.jar下载

    javax.ejb.ObjectNotFoundException.class javax.ejb.PostActivate.class javax.ejb.PrePassivate.class javax.ejb.Remote.class javax.ejb.RemoteHome.class javax.ejb.Remove.class javax.ejb.RemoveException....

    javax.ejb.jar

    javax.ejb.ObjectNotFoundException.class javax.ejb.PostActivate.class javax.ejb.PrePassivate.class javax.ejb.Remote.class javax.ejb.RemoteHome.class javax.ejb.Remove.class javax.ejb.RemoveException....

Global site tag (gtag.js) - Google Analytics