近日在项目中遇到以下错误,着实郁闷了一把:

org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing:com.dhcc.itsm.base.model.User。

这主要是在ManyToOne时遇到的,百度之,发现原因如下:

new了一个新对象,在未保存之前将它保存进了一个新new的对象(也即不是持久态)。

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

但是后来发现同一个model里面有好几个ManyToOne,而且其标注都是:@ManyToOne(fetch=FetchType.LAZY,optional=true) 但是其中一个必须要先查,而其他的就不需要。这个问题先留这里,回头查找原因再补上。

帖子地址:http://topic.csdn.net/u/20081218/12/e74bac38-adfe-4630-aca0-700aa13a5d98.html?482827828

save the transient instance before flushing错误解决办法 【待完善】的更多相关文章

  1. save the transient instance before flushing错误解决办法

    错误原因: new了一个新对象,在未保存之前将它保存进了一个新new的对象(也即不是持久态). 解决办法: 在保存或更新之前把这个对象查出来(这样就是一个持久态) <set name=" ...

  2. 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(参考资料: ...

  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. org.unsaved transient instance - save the transient instance before flushing: bug解决方案

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

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

  6. object references an unsaved transient instance - save the transient instance before flushing异常问题处理

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

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

  8. hibernate 对象状态异常:object references an unsaved transient instance - save the transient instance before flushing

    我的问题出在,删除的对象对应的表中有一个外键,关联着另外一个表,可是另外一个表中没有数据,所以报了这个错误. 参考http://www.cnblogs.com/onlywujun/archive/20 ...

  9. MySQL之Field‘***’doesn’t have a default value错误解决办法

    这篇文章主要介绍了MySQL之Field‘***’doesn’t have a default value错误解决办法,需要的朋友可以参考下 今天,中国博客联盟有博友反馈,zgboke.com无法提交 ...

随机推荐

  1. oracle in语句的坑

    oracle 的in语句最多只能有1000条数据,超出,sql报错.

  2. codevs 1085 数字游戏 dp或者暴搜

    1085 数字游戏 2003年NOIP全国联赛普及组  时间限制: 1 s  空间限制: 128000 KB     题目描述 Description 丁丁最近沉迷于一个数字游戏之中.这个游戏看似简单 ...

  3. tp5.1升级

    # php think version v5.1.23 # composer update Loading composer repositories with package information ...

  4. Delphi.format填充0

    1. ]);// 一共8位数字不够的补零 2. 3. 4. 5.

  5. MySQL索引最左原则

    通过实例理解单列索引.多列索引以及最左前缀原则 实例:现在我们想查出满足以下条件的用户id: 因为我们不想扫描整表,故考虑用索引. 单列索引: ALTER TABLE people ADD INDEX ...

  6. PHP处理MySQL事务代码

    php使用mysqli进行事务处理 <?php$db = new mysqli("localhost","root",""," ...

  7. C++(三十二) — 常对象、常成员变量、常成员函数

    常量:对于既需要共享.又需要防止改变的数据.在程序运行期间不可改变. const 修饰的是对象中的 this 指针.所以不能被修改. 1.常对象 数据成员值在对象的整个生存期内不能改变.在定义时必须初 ...

  8. idea中修改git提交代码的用户名

    1.原因:刚进入这家公司,给同事交接完,直接使用他的电脑,每次提交代码都显示他的用户名,本以为是电脑系统名称呢,可是修改了之后没有效果 2.解决方案: 打开C盘里的 .gitconfig文件 看下gi ...

  9. HDU5521-最短路-建图

    Meeting Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

  10. Hibernate入门_增删改查

    一.Hibernate入门案例剖析:  ①创建实体类Student 并重写toString方法 public class Student { private Integer sid; private ...