Okay, I am so lost on how to fix this one after hours and hours of debugging. I have an entity Chapter which has a collection of Country entities. Country also has a collection of Country entities (ie sub-countries). The exception below is being thrown on the sub-countries collection because in postFlush, isProcessed() returns false.
The exception is:
org.hibernate.AssertionFailure: collection was not processed by flush() at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:183)
This exception occurs because I have an event listener registered with "pre-update" (i have tried post-update also) that attempts to access the Chapter.getCountries() collection.
I wrote a test case that creates a Chapter with one Country in it's collection, detaches both the Chapter and the Country from the session, loads the Chapter, and tries to delete it. When it tries to delete it and commit() is called that is when the exception is thrown.
Accessing the sub-countries collection from the test case does not throw an exception. Only accessing it in the event handler does. Also, I made sure that the Session object used in the test case is the exact object used in the handler that is associated with the collection.
I honestly can't tell if this is a bug with hibernate or not. I updated to the most recent version of hibernate and hibernate-annotations just to make sure I wasn't missing a bug fix. Help with this would be GREATLY appreciated.
The stack trace is below:
Mar 11, 2006 3:18:07 PM org.hibernate.AssertionFailure <init>
SEVERE: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: collection was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:183)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:328)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.ifactory.cms.dao.AbstractDao.delete(AbstractDao.java:332)
at com.ifactory.cms.pdf.ChapterServiceTest.testCollectionBug(ChapterServiceTest.java:156)
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:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at com.ifactory.cms.testsupport.DaoSpringTestCase.runTest(DaoSpringTestCase.java:139)
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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
|