-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Constraint on the latest entry in a one to many association?
PostPosted: Mon Dec 14, 2009 4:54 pm 
Regular
Regular

Joined: Tue Apr 10, 2007 10:02 am
Posts: 56
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.