I have an object mapped like this;
Code:
<class name="Recip"
...
>
<cache usage="read-only" />
<id
name="id"
column="rid"
type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property
...
/>
<one-to-one
name="serSet"
class="SerSet"
outer-join="false"/>
<set name="dnaSet">
<key column="rid"/>
<one-to-many class="AntHist"/>
</set>
</class>
The following query works fine;
Code:
Criteria criteria = session.createCriteria(Recip.class)
.add(Expression.eq("id", new Integer(123456)));
criteria.createCriteria("serSet")
.add(Expression.eq("phenSeqNumber", new Integer(1)));
But if I add this;
Code:
criteria.createCriteria("dnaSet")
.add(Expression.like("typMeth", "DNA"));
Then hibernate performs two selects instead of one. Worst of all, the sql from the first is correct and maps to the object graph correctly but the second select gets bad results and overwrites the object graph.
How do I get it to stop?