I have two classes:
class Parent
{
public virtual Child Child { get; set; }
}
class Child
{
public virtual IList<GrandChild> GrandChildren { get; set; }
}
I have an instance of Parent
loaded from my ISession
, Parent.Child
is lazy loaded (NOT loaded at this point). Child.GrandChildren is also lazy loaded.
If I do this:
session.Save(new Parent { Child = existingParent.Child } );
I get collection [Child.GrandChildren] was not processed by flush()
If I cause existingParent
's Child
property to be loaded, simply by accessing it:
var x = existingParent.Child.Name
the problem goes away. Why is this happening, and how do I solve it - preferably without having to change my fetching strategy?
**Edit: ** Parent has a FK to Child
I'm using NH 2.1.2.4000
Thanks
I had a similar issue, the comment from @Jamie Ide helped me realized what the problem was. I was initializing the collection inside the constructor, which made NHibernate think that the collection was dirty, even if it wasn't required to save that specific object at that point.
The exception I got was: ClassName: ERROR | NHibernate.AssertionFailure: collection [CollectionName] was not processed by flush()
I still want to do this initialization, but I guess I have to find some other solution to that problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With