Hello,
I am using nhibernate in an asp.net application. I am associating a
single session per request model. Although I open the session only
when one of my DAO needs it but I close it in an http module. I am
running into the issue of my Proxies not always initializing, and am
stumped. Here's what I have.
This is a function in a DAO which loads a "User". I am then using the
NHibernatreUtil.Initialize() function which I was under the impression
would load any collections
public User GetByLoginName(string loginName)
{
IQuery query = CurrentSession.CreateQuery("from User where
LoginName=:name");
query.SetString("name", loginName);
User user=query.UniqueResult<User>();
//We shouldn't assume we always to fully load the user.
How do we expose this without leaking nhibernate?
NHibernateUtil.Initialize(user);
return user;
}
What I am finding is that not always but sometimes, my
user.organization.settings collection is uninitalized. Does Initalize
replace the proxy on child entities?
A side question is if I implement ICurrentSessionContext shouldn't a
proxy be able to reattach to a new session? That would make lazy
loading beneficul in asp.net sessions since we could lazy load accross
multiple requests.
Thanks,
Josh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---