I have an object (Assortment) that has a one-to-many relation to another one (AssortmentSlot). The object has a composite-id which needs 3 attributes.
When I load the Assortment object using the following code, the data is filled but the Set for the AssortmentSlots is empty:
Code:
Assortment t = new Assortment();
t.setAssortNo(new Integer(80));
t.setClientBpCd("0009");
t.setClientOdsCd("V");
t = (Assortment) sess.load(Assortment.class, t);
When I load the Assortment with a query using this code, everything works fine and also the set of AssortmentSlots is filled.
Code:
Query q = sess.createQuery("from Assortment a where a.AssortNo = 80 and a.ClientBpCd = '0009' and a.ClientOdsCd = 'V'");
List res = q.list();
Assortment t = (Assortment)res.get(0);
Any ideas?
Thanks, Marcus
Hibernate version: 3.0.5
Mapping documents:<hibernate-mapping package="de.arvatologistics.rim.db">
<class name="Assortment" table="c_assrt_v2">
<composite-id>
<key-property name="AssortNo" column="assort_no" type="java.lang.Integer"/>
<key-property name="ClientBpCd" column="client_bp_cd" type="java.lang.String" />
<key-property name="ClientOdsCd" column="client_ods_cd" type="java.lang.String" />
</composite-id>
<property name="AssortDc" column="assort_dc" type="java.lang.String" not-null="true" />
<property name="AssortTyCd" column="assort_ty_cd" type="java.lang.String" />
<property name="DlvyDt" column="dlvy_dt" type="java.util.Date" />
<property name="FromDt" column="from_dt" type="java.util.Date" />
<property name="Rem" column="rem" type="java.lang.String" />
<property name="ToDt" column="to_dt" type="java.util.Date" />
<property name="StCd" column="st_cd" type="java.lang.String" not-null="true" />
<property name="CUid" column="c_uid" type="java.lang.String" not-null="true" />
<property name="CDt" column="c_dt" type="java.util.Date" not-null="true" />
<property name="UUid" column="u_uid" type="java.lang.String" />
<property name="UDt" column="u_dt" type="java.util.Date" />
<property name="SusyTxCd" column="susy_tx_cd" type="java.lang.String" />
<property name="RecStat" column="rec_stat" type="java.lang.Short" not-null="true" />
<set name="slots">
<key>
<column name="assort_no"/>
<column name="client_bp_cd"/>
<column name="client_ods_cd"/>
</key>
<one-to-many class="AssortmentSlot"/>
</set>
<many-to-one name="module" class="Module" insert="false" update="false">
<column name="mod_no"/>
<column name="client_bp_cd"/>
<column name="client_ods_cd"/>
</many-to-one>
</class>
</hibernate-mapping>
Code: