| The description states the cause would be a lack of flush, but if Hibernate and NHibernate code are still similar on this feature, then it is not the actual cause, because extra lazy collections do adjust their content according to pending operations, after being loaded. So not flushing the session on collection load seems to be intentional, and handled, but with a flaw. At least on NHibernate side, the trouble lies in the sequence of events during lazy collection initialization:
- The collection data is loaded.
- The collection data is adjusted according to pending operations.
- The collection snapshot is taken.
The third point occurs too late, the snapshot being the reference for checking what changes have occurred on the collection. The snapshot should be taken on the unmodified loaded data, not on the data adjusted according to pending operations. (The NHibernate corresponding issue is here, and contains additional considerations.) |