sorry proxy... did you configure a proxy provider (like linfu or castle)? did you see that the sql for the fetch joins the two tables? putting lazy="proxy" works it something in you're mapping\configuration
On Mon, Apr 19, 2010 at 4:37 PM, Armin Landscheidt < [email protected]> wrote: > First I cant see it in the profiler. Second I have a Test which varifies > that all objects are loaded per join. And when I first started the > testrunner for the many-to-one assiciation the test doesn't failed. The test > looks like: > > Child child = new Child(); > Parent parent = new Parent(); > praent.Child = child; > > using(ISession session = sessionFactory.OpenSession){ > session.Save(child); > session.Save(parent); > } > > Parent result: > using(ISession session = sessionFactory.OpenSession){ > result = session.CreateCriteria<Parent>() > > .Add(Restrictions.Eq("Name", "myName")) > .UniqueResult<Parent>(); > } > > Assert.That(parent.Child, Is.EqualTo(child)) > > With the query above the test should fail because the session was closed. > > > 2010/4/19 Diego Mijelshon <[email protected]> > > How are you determining that lazy loading isn't happening? >> >> Diego >> >> >> On Mon, Apr 19, 2010 at 09:44, Armin Landscheidt >> <[email protected]>wrote: >> >>> Hallo >>> >>> I'm loading an Object with a many-to-one association. When I load the >>> parent-object I would expect that the child is loaded lazy. But the >>> child ist loaded directly. How can this be? Is there a default which >>> could be set or something else? >>> >>> The mapping is like this: >>> >>> <class name="Parent" table="Parent" dynamic-update="true" lazy="true" >>> > >>> <id name="Id" unsaved-value="0"> >>> <generator class="native" /> >>> </id> >>> <property name="Name" not-null="true" /> >>> <many-to-one name="Child" column="ChildId" insert="false" >>> update="false" not-found="ignore" /> >>> </class> >>> >>> <class name="Child" table="Child" dynamic-update="true" lazy="true" > >>> <id name="Id" unsaved-value="0"> >>> <generator class="native" /> >>> </id> >>> <property name="Name" not-null="true" /> >>> </class> >>> >>> The Query: >>> var parent = session.CreateCriteria<Parent>() >>> .Add(Restrictions.Eq("Name", "myName")) >>> .UniqueResult<Parent>(); >>> >>> The properties are all virtual. If not NHibernate would throw an >>> exception. >>> Does anyone know a reason why the child is not lazy loaded? >>> >>> -- >>> 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]<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]<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.
