I have a strange problem with join fetching. I have a parent class Constraint with a child class ConstraintTrigger. It is mapped as follows:
Code:
<set name="triggers" table="CST_COLX" fetch="join" access="field">
<key>
<column name="SYS_NM"/>
<column name="CST_NM"/>
</key>
<one-to-many class="ConstraintTrigger"/>
</set>
Constraint has a composite primary key (SYS_NM + CST_NM), ConstraintTrigger has a generated identifier.
The problem is that when I query Constraint, Hibernate uses in its SQL a join between Constraint and ConstraintColumn, quite what you would expect. However, the value for the 'triggers' member is an unintialized PersistentSet, meaning that when you access the collection it performs a separate query to populate the collection, as if no 'fetch=join' was specified.
Anyone any thoughts?