Gaps in index causing null records in collections #2747
Replies: 1 comment 1 reply
-
I could have sworn this was mentioned in the reference manual, but I cannot find it right now. It is mentioned in blog articles from a (former) developer on the project, and it's the same for NHibernate's ancestor, Hibernate. https://ayende.com/blog/4043/nhibernate-mapping-list I believe the basis is that Hibernate and NHibernate are O/R-mappers. It is meant to persist and restore your objects. The List object model preserves such gaps and therefore NHibernate stores and restores it faithfully. It is not NHibernate's job to "clean-up" your objects behind the scenes. Maybe it's possible to use some interceptor, or custom collection type, if you have frequent issues with gaps occurring even though the application itself never creates them? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
If I have a class with a list:
If for a specific "ParentTableID", there are records where there is a gap in "OrderField" (let's say 1, 2, 4), a null item will be added to the collection for each gape.
This has been true since at least version 2.2. Is this just a feature? Why? From my perspective as a developer, I don't really care that there's a gap. Sure, it's weird, because NHibernate automatically updates that field as records are reordered, so the gap was probably caused by a concurrency issue or somebody deleting the record from the backend. But as far as just dealing with that collection in order, I don't care if there is a number missing. Why can't NHibnerate just ignore these gaps?
Beta Was this translation helpful? Give feedback.
All reactions