org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:
详细错误堆栈信息:
org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: xx.xx.TempItem.tempItemCats
at org.hibernate.engine.Collections.processDereferencedCollection(Collections.java:119)
at org.hibernate.engine.Collections.processUnreachableCollection(Collections.java:62)
at org.hibernate.event.def.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:241)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:100)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:49)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy65.save(Unknown Source)
解决原理:
如果是 all-delete-orphan ,那个集合不能用setXXX(List) ,只能用 getXXX().add()
实例代码:
修改前:tempItem.setTempItemCats(set);
修改后:
tempItem.getTempItemCats().clear();
tempItem.getTempItemCats().addAll(set);
org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:的更多相关文章
- spring整合hibernate的时候报异常org.hibernate.HibernateException: createQuery is not valid without active transaction
在整合Spring4+hibernate4时候,当代码执行到dao中CRUD操作时,报了一个异常, org.hibernate.HibernateException: createQuery is n ...
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a ...
- org.hibernate.HibernateException: No Session found for current thread
spring.springmvc和hibernate整合 在sessionFactory.getCurrentSession()时,出现以下异常 No Session found for curren ...
- 问题Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found解决方法
问题Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not fo ...
- 使用hibernate时出现 org.hibernate.HibernateException: Unable to get the default Bean Validation factory
hibernate 在使用junit测试报错: org.hibernate.HibernateException: Unable to get the default Bean Validation ...
- Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
docs.jboss.org文档示例代码:(http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/) sta ...
- org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml at org.hibernate ...
- org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...
- hibernate - Initial SessionFactory creation failed.org.hibernate.HibernateException
对于数据库字段映射, 被映射的字段除了提供 getter方法之外, 还需要提供setter方法. 这也是java bean的一些规范. 例如, 题目中的异常 Initial SessionFactor ...
随机推荐
- ubuntu 下mongodb安装
1.下载: mongodb.org/download 2. 将下载的压缩文件加压到/usr/lib下 3. 建立软链接 ln -s /usr/lib/mongodb-linux-i686-2.6.7/ ...
- 转:jQuery弹出二级菜单
<html> <head> <meta http-equiv="content-type" content="text/html; char ...
- sharepoint2013隐藏左侧导航栏更换新的
$("#zz16_V4QuickLaunchMenu").hide()//隐藏 更换新的 <script type="text/javascript" s ...
- float 在内存中如何存储的
float类型数字在计算机中用4个字节存储.遵循IEEE-754格式标准: 一个浮点数有2部分组成:底数m和指数e 底数部分 使用二进制数来表示此浮点数的实际值指数部分 占用8bit的二进制数, ...
- 使用php脚本查看已开启的扩展
php安装时会将扩展包编译进去,对于一个正在运行中的数据库,查看php的扩展开启状况,第一种方式是通过配置文件查看,另外是通过phpinfo函数查看所有的配置,另外是使用php内置函数来查看,通过脚本 ...
- ffmpeg-20160517-git-bin
ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 4 屏幕1/4大小 S 下一帧 [ -2秒 ] +2秒 ; -1秒 ' +1秒 下一个帧 -> -5秒 f ...
- Django~Test View
https://docs.djangoproject.com/en/1.9/topics/testing/ http://docs.seleniumhq.org/ Automated testing ...
- Android 开发技巧 - Android 6.0 以上权限大坑和权限检查基类封装
简单介绍 关于运行时权限的说法,早在Google发布android 6.0的时候,大家也听得蛮多的.从用户的角度来讲,用户是受益方,更好的保护用户的意思,而对于开发者来说,无疑增加了工作量. 对于6. ...
- DB2中错误信息说明
DB2错误信息SQLCODE SQLSTATE (按sqlcode排序) .分类: db2数据库 2012-10-19 11:35 2942人阅读 评论(0) 收藏 举报 db2sql存储table数 ...
- php数据访问增删查
1.先做一个登陆界面 <form action="chuli.php" method="post"> <div>用户名:<inpu ...