I have a hierarchy of objects in hibernate. I am simply printing the hierarchy out by looping through the hierarchy.
Everything prints out great until I get to the bottom of the hierarchy. I have a Group object which has a collection of Artifact objects. I set up by hibernate mapping to retrieve a Set of artifacts for the Group object. I did this on a column called ratio as opposed to the id column. The Group object has 1 to many relationship with the artifacts. Both objects have the ratio field.
The Group mapping looks like so:
<hibernate-mapping>
<class name="Group" table="Group">
<id name="id" type="int">
<generator class="native" />
</id>
<property name="ratio" type="string"></property>
<set name="artifacts" table="Artifact"
inverse="true" lazy="true" fetch="select">
<key>
<column name="ratio" not-null="true" />
</key>
<one-to-many class="Artifact" />
</set>
</class>
</hibernate-mapping>
The Artifact mapping:
<hibernate-mapping>
<class name="Artifact" table="Artifact">
<id name="id" type="int">
<generator class="native" />
</id>
<property name="ratio" type="string"></property>
</class>
</hibernate-mapping>
The problem is that group objects print out, but the artifacts do not return anything in the queries. I have printed the ratio returned from each group. I have then copied the sql statement out put hibernate outputs and substituted the ratio in the where statement criteria and everything returns correctly:
select artifact0_.ratio as rat2_3_1_, artifact0_.id as id1_, artifact0_.id as id4_0_, artifact0_.ratio as rat2_4_0_from Artifact artifact0_ where artifact0_.ratio='1'
Does anyone know why the hibernate collection is not returning anything?