MappedSuperclass + M:N relation + PostUpdateListener = AssertionFailure: collection [xyz] was not processed by flush()

Description

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.

Explanation:
I have two entities A.class and B.class defined, both inheriting from an common (empty) abstract MappedSuperclass. A and B having a m:n relation between each other. Furthermore there is an PostUpdateListener, which iterates through all properties of updated entities.

Testcase:
Both entities are linked with each (m:n), now i do an update of a simple property of entity A --> MyPostUpdateListener will be called, which iterates through each property of the updated entity(ies). In case of this property was a collection (= property of the m:n relation), the listener furthermore iterates through this collection and get the id of each object in the collection. Doing so will raise following exception :

Caused by: org.hibernate.AssertionFailure: collection [com.qualitype.testcase.server.ejb.entity.EntityB.entitiesOfA] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:333)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
... 29 more

Summarized these error will only occur, in case we are inherating from a mappedSuperClass, having a m:n relation and having the listener touching the collection-elements. But these scenario isn'n very uncommon. We are using hibernate-event listener system for auditing-purposes, so you should understand that touching ever (element in the) collectin is necessary for audit-purposes.

Seems for me like a bug. Need this fixed asap ...

Environment

Windows-XP, Jboss 4.2 GA, Hibernate 3.2.1GA, EJB3

Status

Assignee

DiegoP

Reporter

SS

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

3.2.1
3.2.2
3.2.4.sp1
3.2.3
3.2.4

Priority

Major
Configure