Hibernate version:=3
Mapping documents:
Code:
<class
name="com.sys.dao.bean.PairxordBean"
table="PAIRXORD"
>
<id name="ordid" column="ORDID" type="java.lang.Long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<set name="pairxdets"
inverse="true"
cascade="all-delete-orphan">
<key column="ORDID" />
<one-to-many class="com.sys.dao.bean.PairxdetBean"/>
</set>
<property
name="orddattim"
column="ORDDATTIM"
type="java.sql.Date"
length="10"
/>
... other mappings
<class
name="com.sys.dao.bean.PairxdetBean"
table="PAIRXDET"
>
<id name="detid" column="DETID" type="java.lang.Long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<many-to-one
name="pairxordBean"
column="ordid"
class="com.sys.dao.bean.PairxordBean"
not-null="true" />
... other mappings
CodeCode:
List l = sess.createCriteria(PairxordBean.class)
.add(Restrictions.eq("reqbyid",paiuserBean.getUserid()))
.add(Restrictions.eq("sent",iSent))
.setFetchMode("pairxdets",FetchMode.JOIN)
.setFetchMode("hmembpBean",FetchMode.JOIN)
.list();
With the above mappings and fetching can someone tell me why my I get a PairxordBean object for EVERY PairxdetBean object? In my data base I have one record in the Pairxord table and 2 records in the Pairxdet record with the ordid key equal to the single record in Pairxord. I expected that Hibernate would return one PairxordBean object with a set of two Pairxdet objects in the pairxdets SET. What I get back is two PairxordBean objects that both have the correct pairxdets set in them. Why is this?