Hi,
I'm working on a web application project using NH with ASP.NET 2.0
I'm using NH to load a user from the database in the web application. After I'm loading the user I put the object into http session to be used in other requests. At the beginning of every request I'm attaching the object to the NH session using Lock method. Everything works ok. I even can update the user info in the database using this technique. My problem is when I try to load a collection which is in the relation many - many with a object that is in relation many to one with my user object. I'll give the exactly example:
In the User.hbm.xml I have:
Code:
<many-to-one name="UserType" class="UserType, namespace" insert="false" update="false">
<column name="userTypeId" not-null="false"/>
</many-to-one>
Then in UserType.hbm.xml I have
Code:
<bag name="Properties" table="UserTypes2Properties" inverse="true" lazy="true" cascade="none">
<key column="userTypeId" />
<many-to-many class="Properties, namespace">
<column name="propertyId" not-null="true"/>
</many-to-many>
</bag>
Wehn I try to get the user type using the user from http session (after attaching to nh session) everything goes ok. (user.UserType is ok)....
But when I'm doing user.UserType.Properties I get the error:
Quote:
{"Failed to lazily initialize a collection - no session"}
Any idea how to resolve the problem?
Thank you!