views:

29

answers:

1

Hi, guys

I want to store my object in ASP.NET Session. This object has some lazy loaded properties. When I do postback to my page and get my object from Session, this properties throw LazyInitializationException. Can I rebind this object to newly creates Nhibernate Session to retrieve this properties or I have to create Session and get this object on each request?

+1  A: 

You need to eagerly fetch those objects at the moment you send the SQL query so that they are populated and accessible from the session on the next request. Once the session that was used to retrieve the parent object is closed you cannot fetch them anymore.

Darin Dimitrov
I dont want feth them eagerly, beacuse they are quite large. So, as I understand, I need to fetch this object on each request. Thanks
Tror
But if you are going to store it into the ASP.NET session why would you fetch it on each request? Why not fetch the whole object once and then cache it?
Darin Dimitrov
Maybe I do something wrong? but some objects may contain more than 10000 child objects.
Tror