Description
Boyan Trushev created an issue — 19th May 2011, 1:33:31:
Hi,
This is a follow-up of the problem I described in #NH-2704. There I found that when one-to-one relation is through FK the related property is eagerly loaded. I have been told that this is an expected behavior for one-to-one relation through FK, so I decided to examine also the case when the one-to-one relation is through PK. I have found the same problem there too. It can be easily reproduced with the LazyOneToOne test case. You just have to change
lazy="no-proxy"
tolazy="proxy"
for Employee property of the Person class and for Person property of Employee class in Person.hbm.xml and run the Lazy() test. You'll notice that both the person and it's employee property are loaded on:p = s.CreateQuery("from Person where name='Gavin'").UniqueResult<Person>();And on the next line the test fails as the Employee property was already loaded:
Assert.That(!NHibernateUtil.IsPropertyInitialized(p, "Employee"));