I have a database mapping where a 'project' owns a series of 'status' entries, like...
Code:
<class name="com.project.Project" table="project">
<id name="ID" type="java.lang.Integer" unsaved-value="-1">
<column name="ProjectIntID" />
<generator class="native" />
</id>
<set name="statusEntries" table="project_status" order-by="ProjectStatusChangeDate desc" lazy="true">
<key>
<column name="ProjectIntID" not-null="true" />
</key>
<one-to-many class="com.project.ProjectStatus" />
</set>
<class name="com.project.ProjectStatus"
table="project_status">
<id name="ID" type="java.lang.Integer" unsaved-value="-1">
<column name="ProjectStatusIntID" />
<generator class="native" />
</id>
<property name="projectID" type="java.lang.Integer">
<column name="ProjectIntID" />
</property>
</property>
<component name="state" class="com.eis.project.status.ProjectState">
<property name="value" column="ProjectState"/>
</component>
The status entries are sorted by change date into descending order.
How can I build a HQL query against the 'Project' class that allows me to filter the results by the 'state' property of the latest 'ProjectStatus' entry?