i have unidirectional many-to-one mapping between two classes, both are set to lazy and all fields are virtual and public empty default constructors are available.
I am using spring's HibernateTemplate and when i use Get(A, id) then lazy loading works fine but if i retrieve a named query from the xml (e.g. from A as a where a.score > :score) then i get object "b" initialized. Also, the object "b" in wrapped inside the dynamic proxy (i can see it in the debugger) but what I don't understand is why is it getting initialized on it's own. Any clues pointers would be appreciated
Code:
<class name="Project.Data.Domain.A, Project.Data" table="a" lazy="true">
...
<many-to-one name="B" class="Project.Data.Domain.B, Project.Data">
<column name="bId" not-null="false" />
</many-to-one>
...
</class>
<class name="Project.Data.Domain.B, Project.Data" table="b" lazy="true">
...
</class>