I'm using Hibernate 2.1.6 with an inverse one-to-many association and a "all-delete-arphan" cascade. I can get() and saveOrUpdate() the object graph from the database correctly, but when I'm trying to delete a child by calling setParent(null) or calling childSet.remove(aChild), Hibernate (in both cases) says
don't dereferemce a collection with cascade="all-delete-orphan".
So, if I can't dereference, how should I delete an element from the child set?
Full stack trace of any exception that occurs:
Code:
org.springframework.orm.hibernate.HibernateSystemException: Don't dereferemce a collection with cascade="all-delete-orphan": business.Master.details; nested exception is net.sf.hibernate.HibernateException: Don't dereferemce a collection with cascade="all-delete-orphan": business.Master.details
net.sf.hibernate.HibernateException: Don't dereferemce a collection with cascade="all-delete-orphan": business.Master.details
at net.sf.hibernate.impl.SessionImpl.prepareCollectionForUpdate(SessionImpl.java:2953)
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2890)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2592)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2458)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2260)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2239)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:447)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:375)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:241)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy0.storeMaster(Unknown Source)
at test.TestMasterDetail.testSaveAndUpdateWithOtherObjects(TestMasterDetail.java:155)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)