These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Can't get lazy-loading working
PostPosted: Thu Jul 05, 2007 10:15 am 
Newbie

Joined: Thu Jul 05, 2007 9:44 am
Posts: 4
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 05, 2007 11:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
The design pattern you are looking for is "SessionInView". Google it and there should be plenty to get you going.

In a nutshell, you would write an HttpModule and open a new session and on BeginRequest and close the session on EndRequest. The session is put into the HttpContext so you can get to it anywhere in your ASP.NET code.

_________________
Karl Chu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.