Sorry for my bad explanation. I'll give it a new try:

After Igors posting I found out that the example could have been
simpler.

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

First session:
Read A from Database
Read A.B.C.Name (no problem with lazy loading)

Second session:
Reattach A
Read A.B.D.Name (throws as LazyInitializationException when cascading
is not enabled)

public void TestMethod()
{
    EntA a = null;

    using (ISession session = NHibernateHelper.OpenSession())
    {
        using (session.Transaction)
        {
            a = session.Get<EntA>(1);
            txtResult.Text = a.B.C.Name;
        }
    }

    using (ISession session = NHibernateHelper.OpenSession())
    {
        using (session.Transaction)
        {
            session.Update(a);
            txtResult.Text = a.B.D.Name;  // =>
LazyInitializationException (no Session) when cascading not enabled,
                                                         //      no
problem with cascading e.g. SaveUpdate enabled
        }
    }
}

There is not much more happening in my code. Some lines for the
mappings, some lines to fill the database, one row in each table, and
a WindowsForm to show the results.
If you tell me how, I can post my complete test application.

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