UnsupportedOperationException:删除子实体时

时间:2014-07-07 07:06:19

标签: java hibernate jpa entitymanager

方案: 父类与子类具有OneToMany和OnetoOne关系。 我想删除与父母关联但不与父母关联的所有孩子。并将新子项设置为父项

为此我在关系船映射中使用orphanRemoval = true。 在Code中我这样做:

parent.getChildCollection().clear();
parent.setChildCollection(new ChildCollection());

但我得到以下例外:

    java.lang.UnsupportedOperationException: null
    at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.setRollbackOnly(WebSphereExtendedJtaPlatform.java:139) ~[hibernate-core-4.2.13.Final.jar:4.2.13.Final]
    at org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(AbstractEntityManagerImpl.java:1169) ~[hibernate-entitymanager-4.2.13.Final.jar:4.2.13.Final]
    at org.hibernate.ejb.AbstractEntityManagerImpl.handlePersistenceException(AbstractEntityManagerImpl.java:1289) ~[hibernate-entitymanager-4.2.13.Final.jar:4.2.13.Final]
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1388) ~[hibernate-entitymanager-4.2.13.Final.jar:4.2.13.Final]
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310) ~[hibernate-entitymanager-4.2.13.Final.jar:4.2.13.Final]
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:277) ~[hibernate-entitymanager-4.2.13.Final.jar:4.2.13.Final]
    at com.vw.cop.fh.importframework.persistence.impl.ImportJournalDaoBean.findByFileName(ImportJournalDaoBean.java:74) ~[fispp-ocm-importframeworkpersistence-0.3.6-SNAPSHOT.jar:na]
    at com.vw.cop.fh.importframework.persistence.EJSLocal0SLImportJournalDaoBean_9395ce12.findByFileName(EJSLocal0SLImportJournalDaoBean_9395ce12.java) [na:0.3.6-SNAPSHOT-${env.PE_NAME}/${env.JOB_NAME}/${env.BUILD_ID}/${env.BUILD_NUMBER}/${env.GIT_COMMIT}]
    at fh.orderimportmgmt.orderimport.basicdata.basicimporter.impl.OrderImportDataTransaktionsImporter.getUniqueTransactionId(OrderImportDataTransaktionsImporter.java:337) [fispp-ocm-orderimportimpl-0.3.6-SNAPSHOT.jar:0.3.6-SNAPSHOT-${env.PE_NAME}/${env.JOB_NAME}/${env.BUILD_ID}/${env.BUILD_NUMBER}/${env.GIT_COMMIT}]
    at fh.orderimportmgmt.orderimport.basicdata.basicimporter.impl.OrderImportDataTransaktionsImporter.logOrderChange(OrderImportDataTransaktionsImporter.java:186) [fispp-ocm-orderimportimpl-0.3.6-SNAPSHOT.jar:0.3.6-SNAPSHOT-${env.PE_NAME}/${env.JOB_NAME}/${env.BUILD_ID}/${env.BUILD_NUMBER}/${env.GIT_COMMIT}]
    at fh.orderimportmgmt.orderimport.basicdata.basicimporter.impl.OrderImportDataTransaktionsImporter.importRecord(OrderImportDataTransaktionsImporter.java:161) [fispp-ocm-orderimportimpl-0.3.6-SNAPSHOT.jar:0.3.6-SNAPSHOT-${env.PE_NAME}/${env.JOB_NAME}/${env.BUILD_ID}/${env.BUILD_NUMBER}/${env.GIT_COMMIT}]
    at com.vw.cop.fh.importframework.importmgmt.impl.AbstractTransaktionsImporter.importiereNachVorbereitung(AbstractTransaktionsImporter.java:318) [fispp-ocm-importframework-0.3.6-SNAPSHOT.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88) ~[na:1.7.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.7.0]
    at java.lang.reflect.Method.invoke(Method.java:613) ~[na:2.6 (04-22-2013)]
    at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:6335) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568) [com.ibm.ws.runtime.jar:na]
    at com.vw.cop.fh.base.framework.local.AbstractLocalTxService.aroundInvoke(AbstractLocalTxService.java:95) [fispp-base-local-0.3.5-SNAPSHOT.jar:0.3.5-SNAPSHOT-vwfispp/orderImport-cs-base/2014-06-28_13-57-02/22/b868bf4f271a159698d306cc8489b0bd06431252]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88) ~[na:1.7.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.7.0]
    at java.lang.reflect.Method.invoke(Method.java:613) ~[na:2.6 (04-22-2013)]
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:6226) [com.ibm.ws.runtime.jar:na]
    at fh.orderimportmgmt.orderimport.ejb.basicdata.EJSLocal0SLOrderImportDataTransaktionsImpor_9cbee77a.importiereNachVorbereitung(EJSLocal0SLOrderImportDataTransaktionsImpor_9cbee77a.java) [na:0.3.6-SNAPSHOT-${env.PE_NAME}/${env.JOB_NAME}/${env.BUILD_ID}/${env.BUILD_NUMBER}/${env.GIT_COMMIT}]
    at com.vw.cop.fh.importframework.importmgmt.impl.AbstractImporter.importFile(AbstractImporter.java:200) [fispp-ocm-importframework-0.3.6-SNAPSHOT.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88) ~[na:1.7.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.7.0]
    at java.lang.reflect.Method.invoke(Method.java:613) ~[na:2.6 (04-22-2013)]
    at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:6335) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568) [com.ibm.ws.runtime.jar:na]
    at com.vw.cop.fh.base.framework.local.AbstractLocalTxService.aroundInvoke(AbstractLocalTxService.java:95) [fispp-base-local-0.3.5-SNAPSHOT.jar:0.3.5-SNAPSHOT-vwfispp/orderImport-cs-base/2014-06-28_13-57-02/22/b868bf4f271a159698d306cc8489b0bd06431252]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88) ~[na:1.7.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.7.0]
    at java.lang.reflect.Method.invoke(Method.java:613) ~[na:2.6 (04-22-2013)]
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:6226) [com.ibm.ws.runtime.jar:na]
    at fh.orderimportmgmt.orderimport.ejb.basicdata.EJSLocal0SLOrderImportBasicDataImporter_5821755d.importFile(EJSLocal0SLOrderImportBasicDataImporter_5821755d.java) [na:0.3.6-SNAPSHOT-${env.PE_NAME}/${env.JOB_NAME}/${env.BUILD_ID}/${env.BUILD_NUMBER}/${env.GIT_COMMIT}]
    at fh.orderimportmgmt.orderimport.ejb.AbstractOrderImporterMDB.executeService(AbstractOrderImporterMDB.java:98) [fispp-ocm-orderimportimpl-0.3.6-SNAPSHOT.jar:0.3.6-SNAPSHOT-${env.PE_NAME}/${env.JOB_NAME}/${env.BUILD_ID}/${env.BUILD_NUMBER}/${env.GIT_COMMIT}]
    at com.vw.cop.fh.importframework.ejb.AbstractJobControlMessageDrivenBean.onObjectMessage(AbstractJobControlMessageDrivenBean.java:233) [fispp-ocm-importframework-0.3.6-SNAPSHOT.jar:na]
    at com.vw.cop.fh.base.framework.mdb.AbstractMdb.onMessage(AbstractMdb.java:73) [fispp-base-mdb-0.3.5-SNAPSHOT.jar:0.3.5-SNAPSHOT-vwfispp/orderImport-cs-base/2014-06-28_13-57-02/22/b868bf4f271a159698d306cc8489b0bd06431252]
    at com.ibm.ejs.container.MessageEndpointHandler.invokeMdbMethod(MessageEndpointHandler.java:1164) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.container.MessageEndpointHandler.invoke(MessageEndpointHandler.java:843) [com.ibm.ws.runtime.jar:na]
    at com.sun.proxy.$Proxy183.onMessage(Unknown Source) [na:na]
    at com.ibm.ws.sib.api.jmsra.impl.JmsJcaEndpointInvokerImpl.invokeEndpoint(JmsJcaEndpointInvokerImpl.java:233) [com.ibm.ws.sib.server.jar:1.0.0]
    at com.ibm.ws.sib.ra.inbound.impl.SibRaDispatcher.dispatch(SibRaDispatcher.java:901) [com.ibm.ws.sib.server.jar:1.0.0]
    at com.ibm.ws.sib.ra.inbound.impl.SibRaSingleProcessListener$SibRaWork.run(SibRaSingleProcessListener.java:592) [com.ibm.ws.sib.server.jar:1.0.0]
    at com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:608) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1815) [com.ibm.ws.runtime.jar:na]
[07.07.14 10:17:04:474 CEST] 0000011b BusinessExcep E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "findByFileName" on bean "BeanId(OCM-Orderimport#fispp-ocm-importframeworkpersistence-0.3.6-SNAPSHOT.jar#ImportJournalDaoBean, null)". Exception data: javax.persistence.PersistenceException: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: com.vw.cop.fh.orderimportmgmt.orderimport.persistence.facade.OrderBo.plantSpecificOrderAttributeBos
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:277)
    at com.vw.cop.fh.importframework.persistence.impl.ImportJournalDaoBean.findByFileName(ImportJournalDaoBean.java:74)
    at com.vw.cop.fh.importframework.persistence.EJSLocal0SLImportJournalDaoBean_9395ce12.findByFileName(EJSLocal0SLImportJournalDaoBean_9395ce12.java)
    at fh.orderimportmgmt.orderimport.basicdata.basicimporter.impl.OrderImportDataTransaktionsImporter.getUniqueTransactionId(OrderImportDataTransaktionsImporter.java:337)
    at fh.orderimportmgmt.orderimport.basicdata.basicimporter.impl.OrderImportDataTransaktionsImporter.logOrderChange(OrderImportDataTransaktionsImporter.java:186)
    at fh.orderimportmgmt.orderimport.basicdata.basicimporter.impl.OrderImportDataTransaktionsImporter.importRecord(OrderImportDataTransaktionsImporter.java:161)
    at com.vw.cop.fh.importframework.importmgmt.impl.AbstractTransaktionsImporter.importiereNachVorbereitung(AbstractTransaktionsImporter.java:318)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:613)
    at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:6335)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568)
    at com.vw.cop.fh.base.framework.local.AbstractLocalTxService.aroundInvoke(AbstractLocalTxService.java:95)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:613)
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229)
    at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:6226)
    at fh.orderimportmgmt.orderimport.ejb.basicdata.EJSLocal0SLOrderImportDataTransaktionsImpor_9cbee77a.importiereNachVorbereitung(EJSLocal0SLOrderImportDataTransaktionsImpor_9cbee77a.java)
    at com.vw.cop.fh.importframework.importmgmt.impl.AbstractImporter.importFile(AbstractImporter.java:200)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:613)
    at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:6335)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568)
    at com.vw.cop.fh.base.framework.local.AbstractLocalTxService.aroundInvoke(AbstractLocalTxService.java:95)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:613)
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229)
    at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:6226)
    at fh.orderimportmgmt.orderimport.ejb.basicdata.EJSLocal0SLOrderImportBasicDataImporter_5821755d.importFile(EJSLocal0SLOrderImportBasicDataImporter_5821755d.java)
    at fh.orderimportmgmt.orderimport.ejb.AbstractOrderImporterMDB.executeService(AbstractOrderImporterMDB.java:98)
    at com.vw.cop.fh.importframework.ejb.AbstractJobControlMessageDrivenBean.onObjectMessage(AbstractJobControlMessageDrivenBean.java:233)
    at com.vw.cop.fh.base.framework.mdb.AbstractMdb.onMessage(AbstractMdb.java:73)
    at com.ibm.ejs.container.MessageEndpointHandler.invokeMdbMethod(MessageEndpointHandler.java:1164)
    at com.ibm.ejs.container.MessageEndpointHandler.invoke(MessageEndpointHandler.java:843)
    at com.sun.proxy.$Proxy183.onMessage(Unknown Source)
    at com.ibm.ws.sib.api.jmsra.impl.JmsJcaEndpointInvokerImpl.invokeEndpoint(JmsJcaEndpointInvokerImpl.java:233)
    at com.ibm.ws.sib.ra.inbound.impl.SibRaDispatcher.dispatch(SibRaDispatcher.java:901)
    at com.ibm.ws.sib.ra.inbound.impl.SibRaSingleProcessListener$SibRaWork.run(SibRaSingleProcessListener.java:592)
    at com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:608)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1815)
Caused by: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: com.vw.cop.fh.orderimportmgmt.orderimport.persistence.facade.OrderBo.plantSpecificOrderAttributeBos
    at org.hibernate.engine.internal.Collections.processDereferencedCollection(Collections.java:113)
    at org.hibernate.engine.internal.Collections.processUnreachableCollection(Collections.java:66)
    at org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:257)
    at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:101)
    at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:61)
    at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1130)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1187)
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:268)
    ... 50 more

请建议。

0 个答案:

没有答案