Hi all;
i have a problem with lazy load in batch of collections.
I have the following mapping:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="package.Lot"
table="LOT" dynamic-update="false" dynamic-insert="false" >
<!--<cache usage="read-only" />-->
<id name="id" type="java.lang.Long" column="LIR_K_NUM" >
<generator class="assigned">
</generator>
</id>
<set name="contrats" lazy="true" inverse="true" sort="unsorted"
batch-size="25" >
<key column="LIR_K_NUM"/>
<one-to-many
class="package.Contrat"
/>
</set>
<set name="mouvements" lazy="true" inverse="true" sort="unsorted"
batch-size="25">
<key column="LIR_K_NUM"/>
<one-to-many
class="package.Mouvement"
/>
</set>
<property name="exerciceComptable" type="java.lang.Integer"
column="LIR_P_EXE_COMPT" />
<property name="debitTax" type="java.lang.String"
column="LIR_I_DEB_TAX" />
<property name="typeFlux" type="java.lang.String"
column="LIR_C_TYP_FLX" />
<property name="numeroEnvoi" type="java.lang.Long"
column="LIR_N_NUM_ENVOI" />
<property name="date" type="java.util.Calendar" column="LIR_D_HDMAJ" />
</class>
</hibernate-mapping>
As you can see, this object has 2 lazy-loading collections with a specified batch size.
I have a query which returns several objects of this type.
And then, in the code, i do a get on the collections of each of the objects returned.
However, i see that hibernate generates a new query for each of these gets...
And i hoped thas hibernate would do juste one query loadind 50 collections of these objects on the first get.
What is the problem?
Thank you for the answer in advance.
Jean
|