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

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. sscanf输入总结

    2017-08-21 15:09:47 writer:pprp sscanf很好用的,一般配合gets()来使用 /* theme: usage of sscanf writer:pprp date: ...

  2. Nginx 与 tomcat 部署网站

    http://www.blogjava.net/libin2722/articles/355631.html http://congpeixue.iteye.com/blog/255011 keepa ...

  3. 【转】asp.net 项目在 IE 11 下出现 “__doPostBack”未定义 的解决办法

    最近我们运营的网站有用户反馈在 IE 11 下<asp:LinkButton> 点击出现 “__doPostBack”未定义”,经过一番google,终于知道了原因:ASP.NET 可能无 ...

  4. Java网络编程学习A轮_02_抓包分析TCP三次握手过程

    参考资料: https://huoding.com/2013/11/21/299 https://hpbn.co/building-blocks-of-tcp/#three-way-handshake ...

  5. IntelliJ IDEA 左侧显示/展开类中的方法

    困扰我很久的问题: project直接右键: 打开.关闭对应效果: 之前查到的都是 : 虽然也有类似的功能,但是展开的是右侧窗口中,打开的那个类的: 即使不是我想要的,但也是不错的功能!

  6. python判断指定路径是否存在

    https://www.cnblogs.com/jhao/p/7243043.html

  7. centos网卡配置

    DEVICE=物理设备名 IPADDR=IP地址 NETMASK=掩码值 NETWORK=网络地址 BROADCAST=广播地址 GATEWAY=网关地址 TYPE=Ethernet (网络类型)ON ...

  8. 23.FutureTask基本操作总结

    1.FutureTask简介 在Executors框架体系中,FutureTask用来表示可获取结果的异步任务.FutureTask实现了Future接口,FutureTask提供了启动和取消异步任务 ...

  9. 常用的SpringMVC注解

    1.@RequestMapping() 访问链接编写: 例如: (1).请求方法: 访问链接: (2).请求参数和请求头: 访问链接: 2.@PathVariable 例如: 访问链接: 结果显示: ...

  10. kafka遗忘点

    1.通常,分区数比broker多.follower从leader拉取批量日志应用到自己的日志.消费者消费消息 也是拉取模式. 2.如果leader没有故障,我们就不需要follower!当leader ...