org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:
2014-06-12 14:44
645 查看
详细错误堆栈信息:
解决原理:
实例代码:
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:
- HibernateException - A collection with cascade="all-delete-orphan" was no longer referenced by the o
- hibernate3的cascade导致deleted object would be re-saved by cascade与 A collection with cascade="all-dele
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.zero.space.entity.TblJd#38]解决方法
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [cn.facekee.cms.entity.CmsFansgroup#195]
- hibernate.cache.auto_evict_collection_cache 报错:The instance was not associated with this session/org
- Don't dereference a collection with cascade="all-delete-orphan" ,这是14年遇到的问题,最近在博客上进行整理汇总
- org.hibernate.TransientObjectException: The instance was not associated with this session解决方法
- hibernate cascade="all-delete-orphan"(所有-删除-孤儿)释疑
- 解析xml文件时,错误信息org.xml.sax.SAXParseException:Parser has reached the entity expansion limit "64,000" set by the Application.的解决办法
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- 【hibernate】错误org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- 关于org.hibernate.ObjectNotFoundException: No row with the given identifier exist
- HIbernate级联删除(hibernate 双向一对多中 主表设置cascade="all-delete-orphan",在save时出现
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- Parser exception for xx/AndroidManifest.xml: The reference to entity "z" must end with the ';' delim
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.xxx.xx.model.info.News#15]
- Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: 原因
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread