NHibernate: many-to-one and lazy

纵饮孤独 提交于 2019-12-10 19:24:01

问题


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:


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)



来源:https://stackoverflow.com/questions/6969156/nhibernate-many-to-one-and-lazy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!