Hi, Jose, thanks for the spending your time on this... I did read
Ayende's post and several related ones while trying to resolve the
issue. But unfortunately I can't figure out how it provides a
solution. To try to eliminate misunderstandings, I'll be more
specific. I tried this earlier with NH 3.0.0 GA, now I've checked out
the latest trunk version and I'm still seeing the same thing.

The detail I've concentrated on (and I may be wrong at that) is the
GhostPropertyFixture test in NHibernate.Tests. It uses an Order class
which has a Payment property mapped as non-proxy. The
WillNotLoadGhostPropertyByDefault test method looks like this:

[Test]
public void WillNotLoadGhostPropertyByDefault()
{
        using (ISession s = OpenSession())
        {
                var order = s.Get<Order>(1);
                Assert.IsFalse(NHibernateUtil.IsPropertyInitialized(order,
"Payment"));
        }
}

When I run it, I see that the Payment property gets filled while the
Get<Order>(1) call is running. I would expect it not to get filled at
all... The second interesting thing is that
NHibernateUtil.IsPropertyInitialized returns the wrong result - it
returns false although order.Payment contains an object.

But let's do this another way, I think it's more obvious... I added a
new test, like this:

[Test]
public void WillLoadGhostPropertyOnAccess()
{
        using (ISession s = OpenSession())
        {
                Order order = s.Get<Order>(1);
                Assert.IsFalse(NHibernateUtil.IsPropertyInitialized(order,
"Payment"));

                // trigger on-access lazy load
                var x = order.Payment;
                Assert.IsTrue(NHibernateUtil.IsPropertyInitialized(order,
"Payment"));
        }
}

Here, the second assert fails.

Now, it doesn't work as I would expect it to, but am I expecting the
wrong thing?

Best regards!



On 10 јан, 16:25, José F. Romaniello <[email protected]> wrote:
> Did you ever read my previous message?
>
> Ayende said in his post (link in previous message):
> -The association is *still* lazy loaded (note that in older versions of
> NHibernate, setting it to *no-proxy would trigger eager loading*, this is no
> longer the case).
>
> Please explain with is the bug in the trunk version.
>
> 2011/1/10 Boris Drajer <[email protected]>
>
> > I did some more research on this matter by stepping through NHibernate
> > source, but it's hard for me to grasp its logic for the no-proxy case.
> > But I did get some results - I added a couple of "Debug.WriteLine"s in
> > the code and turned on show_sql in the config, and this is the log I
> > got:
>
> > WireTransfer ctor accessed.
> > Order.Payment.set accessed.
> > Order.Payment.get accessed.
> > Order.Payment.get accessed.
> > -- session.Get<Order>(1) starts (this is the important part) ----
> > 13:56:01,212 INFO  EntityMetamodel:0 - Ghost property fetching
> > available for: NHibernate.Test.GhostProperty.Order
> > 13:56:01,281 ERROR EntityMetamodel:0 - Lazy or ghost property
> > NHibernate.Test.GhostProperty.Order.Payment is not an auto property,
> > which may result in uninitialized property access
> > NHibernate: SELECT order0_.Id as Id0_0_, order0_.Payment as
> > Payment0_0_ FROM Orders order0_ WHERE order0_....@p0;@p0 = 1 [Type:
> > Int32 (0)]
> > NHibernate: SELECT payment0_.Id as Id1_0_, payment0_.Type as Type1_0_
> > FROM Payment payment0_ WHERE payment0_....@p0;@p0 = 1 [Type: Int32
> > (0)]
> > WireTransfer ctor accessed.
> > Order.Payment.set accessed.
> > -- session.Get<Order>(1) finished ---
> > NHibernate: select order0_.Id as Id0_, order0_.Payment as Payment0_
> > from Orders order0_
> > WireTransfer ctor accessed.
> > Order.Payment.set accessed.
> > NHibernate: select payment0_.Id as Id1_, payment0_.Type as Type1_ from
> > Payment payment0_
> > NHibernate: select order0_.Id as Id0_, order0_.Payment as Payment0_
> > from Orders order0_
> > NHibernate: select payment0_.Id as Id1_, payment0_.Type as Type1_ from
> > Payment payment0_
>
> > This shows that the WireTransfer object was created during the loading
> > of order - session.Get<Order>, but more importantly it shows that an
> > sql SELECT command really did load the Payment record, so it wasn't a
> > proxy or empty object of some kind... This looks like a bug to me, can
> > someone confirm - or give me a hint for further investigation?
>
> > Thanks!
>
> > BTW, the error in the log about the auto property doesn't seem to
> > influence this - I tried changing the property but it still behaves
> > the same.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to