3
votes

There is something regarding NHibernate 1.2 (webapp C# aspnet 3.5) and lazy loading that I don't understand and I can't find some clear answer: does many-to-one support lazy loading?

Let's say we have some Person object and a Squeletton object. Both objects are big with many properties. A Person has one and only one Squeletton: myPerson.Squelleton.

Mapping of Person: <many-to-one class='Squeletton' name='Squeletton' column='id_squeletton' lazy='proxy' />

I don't want the Squeletton property to be loaded every time Person is. Using NHProfiler I can see "select" requests for Squeletton even if I don't access the property.

What is wrong: mapping? bad use of many-to-one? NHibernate version? How can I have some lazy loading on Squeletton property?

Thanks in advance.

1

1 Answers

2
votes

Lazy loading is the default, but it should work fine with your mapping.

Are you 100% sure you are not accessing the property? Watching it in the debugger, maybe?

In any case, you should certainly update NHibernate to the last release, 3.2, as 1.2 is really outdated and has been unsupported for ages (as has 2.x)