hi all,
i have A many-to-many B
and i want to construct a DOM like this:
<a1>
<b1/>
<b2/>
</a1>
<a2>
<b3/>
<b4/>
</a2>
the goal is to use only one (sql) query so i made this:
Code:
<mapping of class A>
<set name="bs" table="B" lazy="true" outer-join="true"
<key column="x" />
<many-to-many class="B" column="xx" outer-join="true"
/>
</set>
</mapping of class A>
one shot query:
Code:
"select a,b from A as a join a.bs as b" --> correct all instances are loaded and i have a collection of Objects[]
a1 b1
a1 b2
a2 b3
a2 b4
but i notice that the
collections bs of a1 and a2 are not loaded and then 3000 queries are executed when calling
Databinder db = sessionFactory.openDatabinder();
db.setInitializeLazy(true);
db.bindAll((Collection)result);
Document dom = db.toGenericDOM();
1- if i replace
db.setInitializeLazy(true); by db.setInitializeLazy(false);
the db isn't hit but i do not have my 'bs' in my dom
2- if i replace lazy="true" by lazy="false" , i my mapping file, the 3000 sql queries are called just after the first query
I do not understand since all instances are in the sessions ;(
Thanks for help