tags:

views:

42

answers:

1

Hello. I Have one-to-one relation in my NHibernate mapping:

<many-to-one name="PersonProfile" not-null="true"
    class="PersonProfile" column="profile" cascade="all" lazy="proxy"/>
...
<one-to-one name="Owner" class="Person" property-ref="PersonProfile" 
    constrained="true" lazy="proxy"/>

PersonProfile class have batch-size attribute set. When user.PersonProfile property is hit batch load triggers. But then, when Owner property is loaded it loads from database. Why?

A: 

Because one-to-one relations can not be lazy loaded (in some circumstances).

See this fine explanation: http://stackoverflow.com/questions/389026/nhibernate-how-to-enable-lazy-loading-on-one-to-one-mapping

asgerhallas
It is lazy loaded. But from database - not from fist (session) level cache.
Artem Tikhomirov