-->
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: Collection being eagerly loaded, even though lazy = true!
PostPosted: Sat Aug 27, 2011 12:20 pm 
Newbie

Joined: Fri Nov 13, 2009 8:58 pm
Posts: 4
Hi guys, I have been breaking my head with this issue for the last weeks and I thought that you guys could give me a hand here.
The problem is that I am trying to lazy load a collection, but it gets eagerly loaded all the time, making a huge impact on my app performance. Here it´s the scenario, I describe the model for the 3 classes involved:

Championship : Has one League
League: Has Many Competitors – Belongs to one Championship

When I load the Championship entity, the associated League comes with the list of Competitors already loaded (even though I have lazy=true on my mapping file). I am pasting the relevant parts of the mapping files for these 3 entities:

Code:

<class name=" Championship" table=" Championships">
   <id name="id" type="long" column="id">
      <generator class="native" />
   </id>
<many-to-one name="league" lazy="false" cascade="all" class="League" not-null="true" column="League_FK" unique="true" not-found="ignore"/>
</class>

************************************************************************************************************************
<class name="League" table="League">
   <id name="id" type="long" column="id">
      <generator class="native" />
   </id>

<one-to-one name="championship" class=”Championship” foreign-key="Championship_FK" property-ref="league"/>

      
<list name=" competitorsList" table="Competitors_League" cascade="all" lazy="true">
   <key column="League_FK" not-null="true"/>
   <index column="LeagueIndex" type="long"/>
   <one-to-many class="Competitor" />
</list>
</class>
************************************************************************************************************************

<class name=" Competitor " table=" Competitors_League " >
<key column="id"/>
         
   <many-to-one name="league" lazy="false" class="League"
   not-null="true"
   insert="false"
      update="false"
   column="League_FK" />

</class>



When I load a Championship instance, Championship  league  competitorsList comes already loaded with all list elements. This should not happen since I have lazy = true on my League mapping:
(
Code:
<list name=" competitorsList" table="Competitors_League" cascade="all" lazy="true">
).
I have tried many different approaches and I can get this to work, even though It seems that my mappings are set up correctly.

Can you guys please help me out here? Any help will be really appreciated cause I am kind of stuck here.

Let me know if you need any extra information.
Thanks!


Top
 Profile  
 
 Post subject: Re: Collection being eagerly loaded, even though lazy = true!
PostPosted: Mon Aug 29, 2011 6:28 pm 
Newbie

Joined: Fri Nov 13, 2009 8:58 pm
Posts: 4
Guys, any help as little as it may seem, would be extremely helpful. Do you guys have any clue about this?
Thanks again.


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.