For more details see the attached testcase. I'm sorry, but in the short of time i only got a testcase for jboss-server 4.2. Please deploy the server.ear from /release-directory and then call the /src/client/TestCaseClient.java.
It seems, that touching a lazy (Persistent-)Collection of at least a m:n relation inside a Hibernate event-listener always raises this error:
org.hibernate.AssertionFailure: collection [n-side] was not processed by flush()
I have two entities A. and B. Both having a m:n relation between each other. Furthermore there is an PostUpdateListener, which iterates onUpdate of entitiy through all properties of updated entity.
Both entities are linked with eachother (m:n). If i now do a simple update of a property of entity A --> MyPostUpdateListener will be called, which iterates through every property of the updated entity. In case of this property was a collection (= lazy PersistentCollection of m:n relation), hibernate initializes the collection for further work. I can now run through all objects of the collection, but after all work is done in listener, I get the following exception from postFlush:
Caused by: org.hibernate.AssertionFailure: collection [com.qualitype.testcase.server.ejb.entity.EntityB.entitiesOfA] was not processed by flush()
... 29 more
Attention: EntityB.entitiesOfA is the other-side collection of the m:n relation of the updated EntityA.
We are using hibernate-event listener system for auditing-purposes, so you should understand that touching every (element in the) collection is necessary for audit-purposes.
Seems for me like a serious bug. Need this fixed asap ...
Windows-XP, Jboss 4.2.1GA, Hibernate 3.2.4SP1, EJB3
I went ahead and implemented this since so many people have requested it. However, be aware that this only affects the ability to initialize the proxies/collections. It does not address further flushes to handle any potential changes to those newly initialized things.
Big thanks Steve. This is incredibly helpful. I've got lots of listeners that need this, and some hacky workarounds I will be able to remove when 4.0.1 ships.
Well as long as you realize that this can potentially lead to "missed flushes" you will be fine. Also, be aware that it leads to a larger-than-necessary persistence context ("first level cache").
Please some one tell me class name of context object .