Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-3342 - Lazy loading of ISet throws exception when no result #1292

Open
nhibernate-bot opened this issue Oct 12, 2017 · 0 comments
Open

NH-3342 - Lazy loading of ISet throws exception when no result #1292

nhibernate-bot opened this issue Oct 12, 2017 · 0 comments

Comments

@nhibernate-bot
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants