Class A contains an instance of Class B.
Class A data:
Code:
id colA bId
1 x 1
2 y 2
3 z <null>
Class B data:
Code:
id colB
1 a
2 b
I am trying to use the Criteria API to get a list of all Class A objects, which is sorted by colB in ClassB. The problem is I'm finding that the join to the Class B table is inner and therefore I'm only getting the first 2 ClassA objects NOT ALL 3 as desired!
Code:
Criteria crit = session.createCriteria(ClassA.class)
crit.createCriteria( bId );
crit.setFetchMode( bId, FetchMode.JOIN );
Mapping File ClassA:
Code:
<many-to-one name="bId" class="ClassB" not-null="false" not-found="exception" optimistic-lock="true" update="false" unique="false" insert="false" lazy="no-proxy" embed-xml="false">
<column name="B_FK" length="16" not-null="false"/>
</many-to-one>
I know this topic has been discussed before but i cant seem to find a 100% definitive answer. Although it sounds like it should be possible for such a simple example.
Should it be possible to fetch ALL the Class A objects using the criteria API having specified createCriteria() to ClassB? If so am I missing something really simple
thanks in advance!