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!