views:

37

answers:

2

I have some class with associated list. I want this list not to be loaded when I retrieve the entity, but I want to have an opportunity to load this list later, outside the session in which I cought the entity. Can NHibernate's lazy mechanism do this? Thanks!

A: 

From outside of the session, you will always get an exception when you access an not-yet loaded object.

There is a way to get your objects from a new session. What you want to do is known as "Remote Lazy Loading". See http://www.theserverside.com/news/1363571/Remote-Lazy-Loading-in-Hibernate

aaaa bbbb
Can you show an example of this. I can't find id anywhere.
JooLio
+1  A: 

In theory you can implement your own IBytecodeProvider / ProxyFactory and do whatever you want. But that's quite complex, so you'll want to stick to regular NHibernate usage, which dictates that lazy loading requires an active session. It can be the originating session or you can reattach an entity from a previous session using ISession.Lock()

Mauricio Scheffer