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

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. RabbitMQ入门(3)——发布/订阅(Publish/Subscribe)

    在上一篇RabbitMQ入门(2)--工作队列中,有一个默认的前提:每个任务都只发送到一个工作人员.这一篇将介绍发送一个消息到多个消费者.这种模式称为发布/订阅(Publish/Subscribe). ...

  2. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock'

    查看是否开启服务 # ps -ef | grep mysql root 5605 5457 0 11:45 pts/2 00:00:00 grep mysql 查看my.cnf # cat /etc/ ...

  3. Codeforces Round #409

    第一题很水但是wa了一发,因为没考虑K前面是K的情况 #include<map> #include<set> #include<cmath> #include< ...

  4. 1-11 RHLE7-重定向和文件查找

    在Linux 系统中,一切皆设备Linux系统中使用文件来描述各种硬件,设备资源等例如:以前学过的硬盘和分区,光盘等设备文件sda1   sr0============================ ...

  5. asp.net服务器上无法发送邮件的问题

    前几天为开发的网站做了个发送邮件的功能,但是部署到服务器上无法发送邮件,提示由于目标机器积极拒绝,无法连接.在网上找到了一个解决办法 如果安装了McAfee杀毒软件(按照“手工安装方法”安装),首先需 ...

  6. python 黑客书籍 ——扫描+暴力破解

    https://legacy.gitbook.com/book/germey/net-security/details 网络安全 介绍 构建一个端口扫描器 利用Pexpect模拟SSH连接 利用Pxs ...

  7. vue请求本地json数据

    1.下载vue-resource插件 cnpm install vue-resource 1.2全局引入vue-resource: 在main.js import VueResource from ' ...

  8. 006——数组(六)array_fill()array_filter()array_flip()array_key_exists()array_keys()

    <?php /*数组(六)array_fill()array_filter()array_flip()array_key_exists()array_keys() */ /*1.array_fi ...

  9. textbox和input限制文字长度

    textbox 看下面 要求(限制140,并且显示还剩余多少个文字) <asp:textbox id="txt_xm" runat="server" on ...

  10. RabbitMQ(4) 未路由的消息、TTL和死信

    未路由的消息 当生产这发送的消息到达指定的交换器后,如果交换器无法根据自身类型.绑定的队列以及消息的路由键找到匹配的队列,默认情况下消息将被丢弃.可以通过两种方式 处理这种情况,一是在发送是设置man ...