NHibernate and the second level cache bug: conclustions
Well, I posted that the bug was fixed in the SVN repository, but it was merely moved to another location, not fixed. Futher investigating showed that the same issue appear in Hibernate.
Further investigation showed that this is by design. (Indeed, when trying to fix the "bug", I have run into the same conclustions, and was about to suggest the same "by-design" fix.)
The issue is, to remind you, deleting an object that reside in a collection on the second level cache. The Hibernate FAQ entry about the issue is here. The solution is very simple, you must remove the object from any collections in which it reside before you flush the changes to the database.
This is because NHibernate has no way (at least, no easy way, the suggestion that came up were very complex and fragile) to know in which collections this object reside in. The information exists, in theory, but applications make such wildly different usages of the collections that it is impossible to handle this in a general way.
All in all, this is a good solution, and I did get a chance to dive fairly deeply into NHibernate's code.
Comments
Comment preview