-->
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.  [ 10 posts ] 
Author Message
 Post subject: Lazy Loading
PostPosted: Fri Nov 10, 2006 5:53 am 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
Hibernate version:NHibernate V1.0.2
ASP.NET 2005 V2.0

Dear users,

i'm declaring [b]Lazy=true
in my mapping files and my public properties as virtual ( for each Class) ...

but i'm still getting all my objects Collection loaded, for example :
Department Class have Description , IList Students , when i do

Ilist alldepartments = GetAllDepartments();
I get all the object departments loaded + All the collection loaded !!!

am i missing something ?

Regards,
JojoRico

_________________
In Code We Trust


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 12, 2006 12:07 pm 
Newbie

Joined: Thu Oct 26, 2006 4:49 pm
Posts: 8
Yes, you're missing ;). Lazy loading means, that NHibernate will not load those collections, until you try to access their members.
Try to catch all SQL requests by profiler, and you'll see that NHibernate queries data only at the time when you're reading collection elements.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 12, 2006 6:29 pm 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
Dear Nike,

What about proxies ?!I'm not using proxies in my mapping files.
Byt the wya, when i load a Department object for ex:

Department dept=GetDept(Departmentid);

i get all the collections loaded !! which is cause i'm accessing the property as you've already said , but is it normal that the all the collections of my dept object and are loaded and all their correspondant objects are loaded to ... until i get allmost all the database loaded ?
And how can i "catch all SQL requests by profiler" ?

thanks for your reply
Regards,
JojoRico

_________________
In Code We Trust


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 6:04 am 
Newbie

Joined: Mon Nov 13, 2006 5:51 am
Posts: 3
Location: tunisia
hi,
While the propoerty : "lazy=true" does'nt resolve the problem of loading detail collections, then how could we avoid it.
Excuse but i'm having nearly the same problem.
:)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 10:13 am 
Newbie

Joined: Thu Oct 26, 2006 4:49 pm
Posts: 8
How did you determine, that collection is really loaded immediately after loading class which contains it?
If you looked at "Watch" "Quick Watch", it means that NHibernate loaded collection at the time when you opened collection in watch window, not earlier, not later.
To be sure, use SQL Server profiler and trace all SQL queries executed by your application.
If you're using another database, use it's own profiling tools.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 12:34 pm 
Newbie

Joined: Mon Nov 13, 2006 5:51 am
Posts: 3
Location: tunisia
You are right.
I thaught that at the time i'm looking for my collectiion, the session is already over--> that wasn't true.
my thanks. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 4:48 am 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
Dear naimek,

i'll check the sqlprofiler and let you know if my collections were lazy loaded or not .
thanks for you reply

Regards,
JojoRico

_________________
In Code We Trust


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 4:50 am 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
thanks for Nike !!
Sorry for replying to you naimek

_________________
In Code We Trust


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 5:35 am 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
Dear Nike,

i have sqlserverexpress 2005 intalled with VS2005, i couldn't find any SqlServer Profiler application installed on my pc?
any suggestions?

Regards,
Jojo

_________________
In Code We Trust


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 6:44 am 
Newbie

Joined: Thu Oct 26, 2006 4:49 pm
Posts: 8
SQL Profiler is not included in Express Edition. You're able to get Profiler from any other edition of SQL Server (installing only Client Tools from SQL Server distribution), and connect to SQL Server Express Edition using this approach: http://www.codeproject.com/useritems/SQ ... stance.asp


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.