How to lazyload a component ?
Hello,
I am trying to lazyload all my components.
I have created a Component convention by inheriting from IComponentConvention, and is calling LazyLoad() on the instance, but it doesnt work.
I want it to only load all properties of a component if it is accessed.
How can it be done ? any ideas ? Is it possible ?
Thanks
Martin
ps. i have just reported an issue with IComponentInstance's Properties property returns IEnumerable instead of IEnumerable which would make it possible to enumerate Properties and set Column() on the property.
Then you would be able to make a Component naming convention instead of using GetComponentColumnPrefix().
I wrote about it before but didnt see it registered in the issues list.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Paul Batum on 01 Mar, 2010 07:34 AM
Interesting. I was able to get fluent nhibernate to generate xml with lazy=true using the convention, but when I load the object, its component is still loaded at the same time, rather than lazily. I looked at the NH documentation and it doesn't mention the lazy attribute for components, so I'm not sure what the expected behavior is for lazy=true on a component. I suggest you ask on the NHUsers list what the expected behavior is.
Can you confirm that your xml is being generated with lazy=true? There shouldn't be a problem with this.
3 Posted by Martin on 01 Mar, 2010 12:46 PM
Thanks for you quick reply.
Yes in the XML it sets lazy=true for the component, and it is not complaining about anything.
But it loads the complete object including the component.
4 Posted by Martin From on 01 Mar, 2010 12:54 PM
I have asked in the group if it is possible to lazyload a component.
I have also tried searching about the topic, and it seems it might not be possible.
Thanks again.
Martin
5 Posted by Martin on 02 Mar, 2010 03:58 PM
I got this answer after writing Ayende and he told me to open a JIRA Issue.
http://216.121.112.228/browse/NH-2124
Ayende have wrote about lazy properties here
http://ayende.com/Blog/archive/2010/01/27/nhibernate-new-feature-la...
But it seems it might not apply to Components (as far as i understand the answer), only properties (though component is implemented as a property).
I am not completly sure as i havent been able to make the most recent version of Nhibernate work with the current project and test it.
6 Posted by Martin on 02 Mar, 2010 08:35 PM
Just going to make a quick update again.
I compiled the most recent version of Fluent Nhibernate with the most recent version of NHibernate and it works in the very simple test case i created.
Soo it will become possible when Fluent NHibernate upgrades to a newer version of NHibernate.
Martin :)
Support Staff 7 Posted by James Gregory on 02 Mar, 2010 08:57 PM
Great, thanks for doing the investigation Martin. We currently only track official releases of NHibernate, so this feature probably won't make it into an FNH release for a while.
James Gregory closed this discussion on 02 Mar, 2010 08:57 PM.