hi all,
here is my main mapping file:
Code:
<hibernate-mapping>
<class
name="Article"
table="P_ART_ARTICLE"
dynamic-update="false"
dynamic-insert="false"
mutable="false"
>
<id
name="id"
column="NSU_ART"
type="java.lang.Long"
>
<generator class="assigned">
</generator>
</id>
<map name="familles" table="P_L01_ART_NCL" lazy="true" inverse="false" order-by="DRA_ART_L01 DESC"
where="NSU_VRN='30008' and DAT_FIN_L01 is null" >
<key column="NSU_ART" />
<index column="NSU_VRN" type="integer"/>
<many-to-many class="ElementNomenclature" column="NSU_ENC" />
</map>
<set
name="produits"
table="P_L27_RIN_ART"
lazy="false"
inverse="false"
cascade="none"
sort="unsorted"
order-by="DRA_RIN_L27 DESC"
where = "DAT_FIN_L27 is null"
>
<key
column="NSU_ART"
/>
<many-to-many
class="com.auchan.refUniqueServices.infosProduits.bo.Produit"
column="NSU_RIN"
outer-join="true"
/>
</set>
</class>
</hibernate-mapping>
as you can see i don't want to lazy load the collections, i also want all collections to be loaded in one query.
when i query like this :
Code:
from Article as articles
the main query doesn't contain the "join" but generate 1 query per article to obtain the details, i am in the "n+1" trouble.
Now if i explicitly query using join in hql, the first query returns all i need, but it is followed by n (unecessary) queries....
Code:
"select articles,produits,produitInfoCriteresGestion,produitsFournisseurs,produitFournisseurInfos
from Article as articles
join articles.produits as produits
join produits.produitInfoCriteresGestion as produitInfoCriteresGestion
join produits.produitsFournisseurs as produitsFournisseurs
join produitsFournisseurs.produitFournisseurInfos as produitFournisseurInfos" +
ElementNomenclature as elem "
What am i doing wrong?
Anthony