Hello
I'm trying now since 5 days to get lazy loading work in my webapplication.
Before, lazy was everywhere set to false what causes performance problems.
Basic Handling before:
-open a new session
-execute a query, or doing a update, save or delete inside a transaction
-close the session
worked fine.
Basic Now
-Using a HibernateHelper which returns always the same session
-execute a query, or doing a update, save or delete inside a transaction
-close the session
Like above, lazyloading can not work- i always get an exception "no session".. So i stoped to close the session. Now lazy loading works in general.
But because i never close the session i get errors like: "System.InvalidOperationException: There is already an open DataReader associated with this Connection"..
During updates (session.update(object)) i got Exceptions like "There is another object with the same identifier associated with this session..". When i use session.SaveOrUpdateCopy this works..
I read so much articles which did not help me..
Does anyone have a simple example how to manage the session so that lazy loading works?
Thanks in advance
|