When I try to lazy load a reattached entity I get a
LazyInitializationException (no Session)
I'm not sure if this is a bug or a feature but it is very annoying to
me.

The table structure of my test application looks like this:

A->B->C
      |
      +->D->E

In the first session I read an EntA object from db (see code below).
In the second session I reattach EntA to a new session and I get an
EntC-Object by lazy loading it via EntA
In the third session I reattach EntA to a new session. When trying to
get EntE by lazy loading it I get the above mentioned
LazyInitializationException (no Session).

Can anyone tell me if this is a bug? Did I misunderstand LazyLoading?

using (ISession session = NHibernateHelper.OpenSession())
{
    using (session.Transaction)
    {
        a = session.Get<EntA>(1);
    }
}

using (ISession session = NHibernateHelper.OpenSession())
{
    using (session.Transaction)
    {
        session.Update(a);
        txtResult.Text = a.B.C.Name;
    }
}

using (ISession session = NHibernateHelper.OpenSession())
{
    using (session.Transaction)
    {
        session.Update(a);
        txtResult.Text = a.B.D.E.Name;
    }
}


Table Structure
===========

A (mapped to EntA)
---
Id
Name
BId

B (mapped to EntB)
--
Id
Name
CId
DId

C (mapped to EntC)
--
Id
Name

D (mapped to EntD)
--
Id
Name
EId

E (mapped to EntE)
--
Id
Name

the according entity names are EntA, EntB, EntC, EntD, EntE

Mapping was done with FluentNH
NHibernate Version 2.1
ProxyFactory Castle or LinFu (I tried both)

--~--~---------~--~----~------------~-------~--~----~
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