Hi,
I've got a problem with a query in HQL when I select multiple objects.
Sometimes, (and I don't know why) instead of getting in return of my query an array of Object[], I've only got the first object.
Of course I can get my second object by my first one with the relation between them, but obviouly it's not my favorite method.
I'm using Hibernate 2.1.1
There is my mapping and query :
Code:
<class name="...PtlTypeChambre" table="xpc_ptl_type_chambre">
<composite-id name="xpcPK" class="...PtlTypeChambrePK">
<key-property column="replique" name="replique" />
<key-property column="code_exp" name="codeExp" />
<key-property column="code_ptl" name="codePtl" />
<key-property name="numTypeChambre" column="num_tpc" />
</composite-id>
<version name="version" column="num_version" />
<property name="libTypeChambre" column="lib_tpc" />
<set name="setTypesChambreJour" lazy="true" inverse="true" cascade="delete">
<key>
<column name="replique" />
<column name="code_exp" />
<column name="code_ptl" />
<column name="num_tpc" />
</key>
<one-to-many class="..TypeChambreJour" />
</set>
<set name="setDotations" lazy="true" inverse="true" cascade="delete">
<key>
<column name="replique" />
<column name="code_exp" />
<column name="code_ptl" />
<column name="num_tpc" />
</key>
<one-to-many class="...PtlDotation" />
</set>
<set name="setRatios" lazy="true" inverse="true" cascade="delete">
<key>
<column name="replique" />
<column name="code_exp" />
<column name="code_ptl" />
<column name="num_tpc" />
</key>
<one-to-many class="...PtlRatio" />
</set>
</class>
Code:
<class name="...TypeChambreJour" table="xtc_type_chambre_jour">
<composite-id name="xtcPK" class="...TypeChambreJourPK">
<key-property name="replique" column="replique" />
<key-property name="codeExp" column="code_exp" />
<key-property name="codePtl" column="code_ptl" />
<key-property name="numTpc" column="num_tpc" />
<key-property name="dateTcd" column="date_tcd" />
</composite-id>
<version name="version" column="num_version" />
<property name="nbOccVeille" column="nb_occ_veille" />
</class>
The query :
Code:
select
xpc, xtc
from
PtlTypeChambre xpc
left outer join fetch xpc.setTypesChambreJour xtc
where
xpc.id.replique = 'A'
and xpc.id.codeExp = 1
and xpc.id.codePtl = 1
So if someone can explain where I'm wrong, I'd be pleased.
Thanks in advance.
Jerome