Hello everyboy.
I have a question on optimized loading on Hinernate 3.2.1 .
I make the following mapping [see (1)] and try to load a graph in only one select.
So i create all my beans [see (2)] and in an other session try to get only Demande [see (3)].
In fact, i don't obtain one select but two [see (3)].
Is there any reason why Hibernate can't do that in one select ?
Thanks
----------------------------------------------------------------------------------------------------------------------
(1)
<!-- per-concrete-class -->
<class name="Demande" table="A_DEM">
<id name="id">
<generator class="hilo"/>
</id>
<property name="m_demandeOrigine" column="DDE_ORIGINE"/>
<many-to-one
name="m_dossierAffectationReprise"
class="DossierAffectation"
column="DOSSIER_ID"
unique="true"
fetch="join"
cascade="all"/>
</class>
<!-- per-concrete-class -->
<class name="DossierAffectation" table="A_DAFFABS" lazy="false">
<id name="id">
<generator class="hilo"/>
</id>
<property name="m_demande" column="M_DEMANDE"/>
<union-subclass name="DossierAAffecter" table="A_DOSSAAFF">
</union-subclass>
<union-subclass name="DossierAffecte" table="A_DOSSAFF">
<!-- one-to-one name="m_dossierExamen" class="DossierExamen" fetch="join"/ -->
<many-to-one
name="m_dossierExamen"
class="DossierExamen"
column="DOSSEXA_ID"
unique="true"
fetch="join"
cascade="all"/>
</union-subclass>
</class>
<!-- per-hierarchy -->
<class name="DossierExamen" table="A_DEXAM" lazy="false">
<id name="id">
<generator class="hilo"/>
</id>
<discriminator column="TYPE_CLASS" type="string"/>
<subclass name="Examen" discriminator-value="0505">
</subclass>
<subclass name="Decision" discriminator-value="0507">
<property name="m_validee" column="EST_VALIDEE"/>
</subclass>
</class>
----------------------------------------------------------------------------------------------------------------------
(2)
Demande lDemande = new Demande();
lDemande.setM_demandeOrigine("lDemande");
DossierAffecte lDossierAffecte = new DossierAffecte();
lDossierAffecte.setM_demande("lDossierAffecte");
lDemande.setM_dossierAffectationReprise(lDossierAffecte);
Decision lDecision = new Decision();
lDecision.setM_validee("lDecision");
lDossierAffecte.setM_dossierExamen(lDecision);
s.persist(lDemande);
----------------------------------------------------------------------------------------------------------------------
(3)
Demande lDemande2 = (Demande) s.get(Demande.class, this.idDemande);
----------------------------------------------------------------------------------------------------------------------
(4)
--->select
demande0_.id as id0_1_,
demande0_.DDE_ORIGINE as DDE2_0_1_,
demande0_.DOSSIER_ID as DOSSIER3_0_1_,
dossieraff1_.id as id1_0_,
dossieraff1_.M_DEMANDE as M2_1_0_,
dossieraff1_.DOSSEXA_ID as DOSSEXA1_3_0_,
dossieraff1_.clazz_ as clazz_0_
from
A_DEM demande0_
left outer join
(
select
M_DEMANDE,
null as DOSSEXA_ID,
id,
0 as clazz_
from
A_DAFFABS
union
select
M_DEMANDE,
null as DOSSEXA_ID,
id,
1 as clazz_
from
A_DOSSAAFF
union
select
M_DEMANDE,
DOSSEXA_ID,
id,
2 as clazz_
from
A_DOSSAFF
) dossieraff1_
on demande0_.DOSSIER_ID=dossieraff1_.id
where
demande0_.id=?
--->select
dossierexa0_.id as id4_0_,
dossierexa0_.EST_VALIDEE as EST3_4_0_,
dossierexa0_.TYPE_CLASS as TYPE2_4_0_
from
A_DEXAM dossierexa0_
where
dossierexa0_.id=?
|