Regarding 1: The fix involves having AbstractFlushingEventListener#postFlush( session ) call PersistentCollection#unsetSession( session ) if the collection is dereferenced.This would be late enough in the flush cycle, wouldn't it?
Regarding 2: The specific case here is that Hibernate needs to know that the actual collection reference has changed either to null, or to some other collection reference so that Hibernate will update the EntityEntry state appropriately. CollectionType#isDirty ultimately returns !CollectionType#isEqual, which only returns true if the PersistentCollection is the same reference or wraps the same collection. In other words, a change only in the collection contents will not dirty the entity; only a change in collection reference will dirty the entity. Would this be acceptable when the entity is not versioned?
Regarding 3: IIRC, this only fixes things when the entity is versioned, because, currently, dirtiness is only checked if the collection owner is versioned.
|