You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stefan Reicht created an issue — 5th December 2012, 12:19:49:
I tried to update NHibernate to 3.3.2 GA from 2.1.2 GA. With 2.1.2 I used ByteCode.Castle as proxy.
During testing I got this error:
Message: "Object reference not set to an instance of an object."
StackTrace: " at NHibernate.Collection.PersistentBag.GetEnumerator() in p:\nhibernate-core\src\NHibernate\Collection\PersistentBag.cs:line 431"
It occures when I try to read from an ISet, which is lazy loaded and there are no results from the database.
I also added a little example (only written with Notepad).
I solved this problem by adding following line in the DefaultInitializeCollectionEventListener, just before the reading from cache/database:
collection.BeforeInitialize(ce.LoadedPersister, 0);
I am not sure if it´s the best solution, but it works for my cases.
Oskar Berggren added a comment — 5th December 2012, 20:48:41:
I don't have the code at the moment, but I find it a little odd that you get exception from PersistentBag when you are handling an ISet. Is the mapping correct?
Stefan Reicht added a comment — 6th December 2012, 5:45:49:
With NH 2.1.2 and ByteCode.Castle it worked fine.
Therefore I think its ok.
I forgot to write that I am using an CompositeID for the ISet mapping.
Maybe this is also relevant for solving the problem.
The text was updated successfully, but these errors were encountered:
Stefan Reicht created an issue — 5th December 2012, 12:19:49:
Oskar Berggren added a comment — 5th December 2012, 20:48:41:
Stefan Reicht added a comment — 6th December 2012, 5:45:49:
The text was updated successfully, but these errors were encountered: