-->
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.  [ 6 posts ] 
Author Message
 Post subject: lazy loading not working, defaulting to immediate fetching
PostPosted: Mon Nov 08, 2004 2:57 pm 
Newbie

Joined: Thu Nov 04, 2004 1:37 pm
Posts: 10
for some reason my many-to-one objects refuse to lazy load. rather when the parent is created all child objects are fetched with separate sql statements immediately. all the child objects have lazy="true". is there something missing here?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 3:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You are surely accessing the collection somewhere, perhaps in the setter. Use your debugger.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 4:48 pm 
Newbie

Joined: Thu Nov 04, 2004 1:37 pm
Posts: 10
I know for a fact that i am not accessing any fields from any of the many-to-one objects. i turned on the debug and looked at the output and i am still not sure why it is forcing the associations to be lookedup. here is a little of the debgu output:

first the sql for the main object is run then....

14:29:06,814 DEBUG SessionImpl:2202 - resolving associations for [edited/myobject#9000]
14:29:06,814 DEBUG SessionImpl:1986 - loading [edited/mysubobject#2500]
14:29:06,844 DEBUG SessionImpl:1986 - loading [edited/mysubobject2#12906]
14:29:06,844 DEBUG SessionImpl:3933 - creating collection wrapper:[edited/mysubcollection#9000]
14:29:06,864 DEBUG SessionImpl:2226 - done materializing entity [edited/myobject#9000]
14:29:06,864 DEBUG SessionImpl:3116 - initializing non-lazy collections
14:29:14,601 DEBUG SessionImpl:2083 - attempting to resolve [edited/mysubobject#2500]
14:29:14,611 DEBUG SessionImpl:2116 - object not resolved in any cache [edited/mysubobject#2500]
14:29:14,611 DEBUG EntityPersister:416 - Materializing entity: [edited/mysubobject#2500]

after this the sql for subobject1 and subobject2 are ran.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 5:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Is your collection really mapped with lazy="true"? You know, for example posting the relevant parts of your mapping would surely get you better answeres faster.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 09, 2004 6:42 pm 
Newbie

Joined: Thu Nov 04, 2004 1:37 pm
Posts: 10
ok.
here is the relevant part from the parent object:

<many-to-one name="agent" column="DB_BP_CSR_ID" class="Agent" outer-join="auto" />

here is the relevan part from the child object:

<class name="Agent" table="TBL_AGENCY_USER" lazy="true">

also, the agent object has two more child object. these children are not loaded when the parent is. only this agent object seems to want to load.


shane


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 09, 2004 8:35 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
You're not doing any funky toString()'ing of objects for debugging purposes, are you? (Or any other usage of collections)

We had this problem once and it was caused by a naively written toString() method, so when you debugged the parent object a side-effect was that the children collections were loaded.

This is quite nasty when you realise that having debugging turned on/off can affect the behaviour of your app (ie. when children objects are loaded). It can be especially nasty with detached objects, results in issues like "when debug is off, we get LaziInitialization exceptions").

_________________
Cheers,
Shorn.


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