title: get updated row in one to many mapping using hibernate
body: <p>I have two entities Issue and <code>Issue_Tracker</code>. I have joined both table in an one to many mapping. In <code>Issue_Tracker</code> , We can have multiple entries like</p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>  issue_id  tracker_status      tracked_time
      123     Assigned           1/8/2013 11:44
      123     Assigned           1/8/2013 11:45
      123     Completed          1/8/2013 11:52
      32      Assigned           1/9/2013 16:46
      33      Assigned           1/9/2013 16:47
      33      Cancel             1/9/2013 16:49 
  </code></pre>
  
  <p>I want to Order the Issue_tracker entity by tracked_time so I can get only last update <code>tracker_status</code>.I am using criteria to get data,However I am getting first entry for example : for issue_id 123, I get tracker_status as Assigned , But I want to fetch <code>tracker_status : Completed</code> for id 123. How to achieve this. My DAO is as follows</p>
  
  <pre class="lang-java prettyprint-override"><code>     Criteria criteria = session.createCriteria(Issue.class);
       criteria.setFirstResult(from);
       criteria.setMaxResults(size);
       criteria.setFetchMode("Issue.issueTracker",FetchMode.JOIN);
       criteria.add(Restrictions.eq("status", "Escalate To"));
        return criteria.list();
  </code></pre>
  
  <p><strong>Issue.java</strong>    </p>
  
  <pre class="lang-java prettyprint-override"><code>public class Issue implements Serializable
          {
          private Integer issue_id;
          private String  issue_description;
          private Date issue_raised_date;
          private Set&lt;Issue_Tracker&gt; issueTracker = new HashSet&lt;Issue_Tracker&gt;(0);
  
  
  
          @OneToMany(fetch=FetchType.LAZY, mappedBy="issue_id")
          public Set&lt;Issue_Tracker&gt; getIssueTracker() {
          return issueTracker;
      }
  
          public void setIssueTracker(Set&lt;Issue_Tracker&gt; issueTracker) {
          this.issueTracker = issueTracker;
  </code></pre>
  
  <p><strong>Issue_Tracker.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>public class Issue_Tracker implements Serializable
  {  
       private Integer   issue_id;
       private String    tracker_status;
       private Timestamp tracked_time;
  </code></pre>
  
  <p>I hope you guys can get what i am trying to ask, any help?</p>