一、异常: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. vue-cli安装sass

    npm install node-sass --save npm install sass-loader --save 也可以使用淘宝镜像 npm install -g cnpm --registry ...

  2. SQL UNPIVOT和PIVOT

    /* table_source PIVOT( 聚合函数(value_column) FOR pivot_column IN(<column_list>) ) 完整语法: table_sou ...

  3. es6+最佳入门实践(2)

    2.解构赋值 2.1.什么是解构赋值? 什么是解构赋值?这里的关键字还是赋值,这是说如何去赋值的问题,这里说的解构可以理解为解散重新构造,所以解构赋值可以理解为解散重新构造后进行赋值,通常是左边一种结 ...

  4. transition transform animate的使用

    注:代码显示效果可以自行粘贴复制查看 transition(过渡),主要是关注property的变化主要有四个属性transition-property.transition-durantion.tr ...

  5. linux--lsof

    lsof(list open files)是一个列出当前系统打开文件的工具.在linux环境下,任何事物都以文件的形式存在,通过文件不仅仅可以访问常规数据,还可以访问网络连接和硬件.所以如传输控制协议 ...

  6. 题(NOIP模拟赛Round #10)

    题目描述: 有一张的地图,其中的地方是墙,的地方是路.有两种操作: 给出个地点,询问这个地点中活动空间最大的编号.若询问的位置是墙,则活动空间为:否则活动空间为询问地点通过四联通能到达的点的个数.如果 ...

  7. COMPANY_点取消会卡死的解决方法

    // OLD void ctonedlg::onbtn_basedir_clicked() {     m_basedir = getUserSelectDir();     doSearchDir( ...

  8. IOS-NSDate之今天,昨天,这周,这个月,上个月

    http://blog.csdn.net/xdrt81y/article/details/8425727 今天跟大家讨论日期的用法,相信大家在项目中,经常会设置一个默认时间段,比如一周前到今天.下面教 ...

  9. AlarmManager定时闹钟

    一.AlarmManager介绍: AlarmManager是Android中常用的一种系统级别的提示服务,在特定的时刻为我们广播一个指定的Intent.简单的说就是我们设定一个时间,然后在该时间到来 ...

  10. python接口自动化8-参数化【转载】

    本篇转自博客:上海-悠悠 原文地址:http://www.cnblogs.com/yoyoketang/tag/python%E6%8E%A5%E5%8F%A3%E8%87%AA%E5%8A%A8%E ...