一、异常:org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing:

  这主要是在ManyToOne级联操作时遇到,比如new了一个新对象,在未保存之前将它保存进了一个新new的对象(也即不是持久态)。

  解决办法是在保存或更新之前把这个对象查出来(这样就是一个持久态)。

  解决办法是将many-to-one的级联设为: cascade="save-update,persist"

  四种 CASCADE 类型:
    * PERSIST:持久保存拥有方实体时,也会持久保存该实体的所有相关数据。
    * MERGE:将分离的实体重新合并到活动的持久性上下文时,也会合并该实体的所有相关数据。
    * REMOVE:删除一个实体时,也会删除该实体的所有相关数据。
    * ALL:以上都适用。

二、异常1:not-null property references a null or transient value
  解决方法:将“一对多”关系中的“一”方,not-null设置为false

  异常2:org.hibernate.TransientObjectException: object references an unsaved transient instance
  解决方法:cascade="save-update,persist"

  异常3:org.hibernate.QueryException: could not resolve property
  解决方法:"from Category category where category.userID = :userID"修改为"from Category category where userID = :userID"或者"from Category category where category.user.id =
:userID"

  异常4:could not initialize proxy - the owning Session was closed
  解决方法:设置lazy为false

object references an unsaved transient instance - save the transient instance before flushing异常问题处理的更多相关文章

  1. object references an unsaved transient instance - save the transient instance before flushing错误

    异常1:not-null property references a null or transient value解决方法:将“一对多”关系中的“一”方,not-null设置为false(参考资料: ...

  2. ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [object references an unsaved transient instance - save the transient instance before flushing: cn.itcast.domain.Custom

    本片博文整理关于Hibernate中级联策略cascade和它导致的异常: Exception in thread "main" org.hibernate.TransientOb ...

  3. object references an unsaved transient instance save the transient instance before flushing

    object references an unsaved transient instance save the transient instance before flushing 对象引用未保存的 ...

  4. Hibernate的一个问题object references an unsaved transient instance - save the transi5

    1 我做了一对多和多对一的双向关联关系,在User这一方@ManyToOne已经设置了级联Cascade,这样在测试程序中保存User时,Group也应该自动保存,为什么会抛出以下的异常: (我是按着 ...

  5. object references an unsaved transient instance - save the transient instance before flushing: com.jspxcms.core.domain.ScTeam

    object references an unsaved transient instance - save the transient instance before flushing: com.j ...

  6. ManyToMany【项目随笔】关于异常object references an unsaved transient instance

    在保存ManyToMany  时出现异常: org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.Tran ...

  7. 三大框架常遇的错误:hibernate : object references an unsaved transient instance

    hibernate : object references an unsaved transient instance 该错误是操作顺序的问题,比如: save或update顺序问题---比方学生表和 ...

  8. object references an unsaved transient instance【异常】

    [异常提示] TransientObjectException: object references an unsaved transient instance -save the transient ...

  9. org.unsaved transient instance - save the transient instance before flushing: bug解决方案

    最近开发和学习过程中,遇到很多零碎的知识点,在此简单地记录下: 1.遇如下bug: org.unsaved transient instance - save the transient instan ...

随机推荐

  1. 【bzoj3668】[Noi2014]起床困难综合症 贪心

    原文地址:http://www.cnblogs.com/GXZlegend/p/6797090.html 题目描述 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神 ...

  2. c#后的完整cookie

    http://www.cnblogs.com/top5/archive/2010/04/11/1709457.html c#设置 webbrowser的请求cookie,可以通过fiddler分析co ...

  3. vs 2013 update2无法打开 edmx文件

    解决方案:在edmx文件上右键,选择ado.net entity data model designer,即可正常打开!

  4. (八) stm8程序段定位,理解lkf文件

    要修改.lkf 文件. ST 有个中文文档: 如何基于STM8S系列MCU进行项目开发 页29/34 当“Auto”选择框被勾选时,.lkf文件会自动生成在项目主目录下的 debug/ 和 relea ...

  5. java基础练习 15

    import java.util.Scanner; public class Fiftheen { /*有n个人围成一圈,顺序排号.从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下 ...

  6. Resin4 自定义端口

    1. Resin4配置文件发生了较大变化,分为: app-default.xml  web应用配置 cluster-default.xml  集群配置 health.xml -- 非pro版不支持 r ...

  7. django返回响应对象

    Django的视图必须要返回一个HttpResponse对象(或者其子类对象),不能像flask一样直接返回字符串. Django: return HttpResponse("Hello&q ...

  8. 【C语言】指针增减

    int *pa = NULL; ; printf("%x\n", pb); char *pca = NULL; ; printf("%x\n", pcb); s ...

  9. Fiddler抓包11-HTTPS证书Actions无法导出问题【转载】

    本篇转自博客:上海-悠悠 原文地址:http://www.cnblogs.com/yoyoketang/tag/fiddler/ 前言 在点Actions时候出现Export Failed:The r ...

  10. 【原创】Win Server 2012R2 IIS 详细配置(多图详解)

    1. 前期准备 1) 2012系统的IIS安装的时候,需要系统安装盘里面的一些软件,因此需要在安装前将系统安装盘挂载到服务器的盘符上,以便使用. 2. 添加角色和功能 打开服务器管理器,点击管理菜单, ...