Hi!
Using the Criteria API I'm trying to load all the object graph in one SQL select using outer joins but it seems that all associated objects are all loaded in the first query but also each one individually:
<hibernate-mapping package="sondage">
<class name="SondageInfo" table="Sondage" mutable="false">
<cache usage="read-only"/>
<id name="sondageGPK" type="long" unsaved-value="null">
<generator class="GPKGenerator">
...
</generator>
</id>
<property name="organisationId"/>
...
<one-to-one name="marchandiseTransporteur"
class="MarchandiseTransporteur"
property-ref="sondageGPK"
cascade="none" outer-join="true"/>
...
</hibernate-mapping>
The code:
Criteria c = session.createCriteria(SondageInfo.class);
c.add(Expression.eq("sondageGPK", new Long(4980736)));
Hibernate result output:
1st query:
select this.sondageGPK as sondageGPK1_, ... from Sondage this left outer join MarchandiseTransporteur marchandis1_ on this.sondageGPK=marchandis1_.sondageGPK where this.sondageGPK=?
2nd query:
select marchandis0_.marchandiseTransporteurGPK ...from MarchandiseTransporteur marchandis0_ where marchandis0_.sondageGPK=?
As you can see the first query loads everything for table "Sondage" but also for table "MarchandiseTransporteur" using a left outer join, but there is a second query issued by Hibernate which loads "MarchandiseTransporteur" again? The association is loaded twice why???
Thanks
Regards,
Christian
|