Problem setting Not.LazyLoad() on OneToManyCollectionInstance

Cameron's Avatar

Cameron

19 Jul, 2010 11:18 AM via web

Hi,

I've been trying to work out a problem where I try to set instance.Not.LazyLoad() from an IHasManyConvention, and lazy="true" appears in the mappings instead of the expected lazy="false".

This is the code I have in my convention:

public class HasManyConvention : IHasManyConvention
{
    public void Apply(IOneToManyCollectionInstance instance)
    {
          if(switch) instance.Not.LazyLoad();
    }
 }

If the switch is true, it puts lazy="true" in my hbms, otherwise it doesn't put anything in there.

It seems that Conventions/Instances/OneToManyCollectionInstance.cs is declaring its own private new bool nextBool rather than using the superclass' protected bool nextBool (from CollectionInstance). The result of this is that when you call Not, it sets nextBool=false on the OneToManyCollectionInstance object then LazyLoad() uses the CollectionInstance's nextBool which is still set to true.

Simply removing

private new bool nextBool;

from OneToManyCollectionInstance.cs makes it behave as I'd expect it to. Removing the new Not property would probably work too.

Link to OneToManyCollectionInstance.cs: http://github.com/jagregory/fluent-nhibernate/blob/master/src/Fluen...

Thanks,
Cameron

  1. 2 Posted by James Cracknell on 21 Jul, 2010 04:40 PM

    James Cracknell's Avatar

    I will confirm this issue.

    Has anyone come up with a temporary workaround that doesn't involve using mixed mapping paradigms or maintaining a fork?

  2. Support Staff 3 Posted by James Gregory on 22 Jul, 2010 11:00 AM

    James Gregory's Avatar

    You could send us a pull request with the fix...

  3. Support Staff 4 Posted by Paul Batum on 25 Jul, 2010 09:04 AM

    Paul Batum's Avatar

    I've received the pull request and applied it to my dev branch (along with
    an extra test).

  4. 5 Posted by David on 12 Aug, 2010 03:03 AM

    David's Avatar

    I noticed an issue with setting Not.Inverse() in a HasManyConvention. (The generated xml still showed inverse="true")

    I'm guessing that'd be a related issue...

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is the opposite of down?