title: fetch only last entries using criteria(Hibernate)
body: <p>I have two entities <code>Issue</code> and <code>Issue_Tracker</code>.</p>
  
  
  
  <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>when i left join both the table and i get following data as follows using query:</p>
  
  <pre class="lang-java prettyprint-override"><code>SELECT issues.issue_id,
         issues.issue_description,
         issue_tracker.tracker_status,
         issue_tracker.tracked_time
  FROM issues
       LEFT JOIN issue_tracker on issues.issue_id = issue_tracker.issue_id 
       WHERE issues.status = "Escalate To"
  </code></pre>
  
  <p>and output is </p>
  
  <pre class="lang-java prettyprint-override"><code>  issue_id  tracker_status      tracked_time
      123     Assigned           1/8/2013 11:44   //1st entry
      123     Assigned           1/9/2013 11:45
      123     Completed          1/10/2013 12:52  // last entry
  
      32      Assigned           1/9/2013 16:46   //1st entry
  
      32      Assigned           1/10/2013 18:46  //last entry
  
      33      Assigned           1/9/2013 16:47   //1st entry
  
      33      Cancel             1/9/2013 17:49  //last entry
  </code></pre>
  
  <p>Now when i did these join using criteria, I get these results</p>
  
  <pre class="lang-java prettyprint-override"><code>      issue_id  tracker_status      tracked_time
          123     Assigned           1/8/2013 11:44 //1st entry of issue_id 123
          32      Assigned           1/9/2013 16:46
          33      Assigned           1/9/2013 16:47
  </code></pre>
  
  <p>using following criteria </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"));
  </code></pre>
  
  <p>Now expected output is </p>
  
  <pre class="lang-java prettyprint-override"><code>      issue_id  tracker_status      tracked_time
          123     Completed          1/10/2013 12:52 // last entry
          32      Assigned           1/10/2013 18:46 //last entry
          33      Cancel             1/9/2013 17:49  //last entry
  </code></pre>
  
  <p>How to achieve this, I am stuck here since last three days, any help would be great, is it happening because of this line where i am trying one to many mapping</p>
  
  <p><code>private Set&lt;Issue_Tracker&gt; issueTracker = new HashSet&lt;Issue_Tracker&gt;(0);</code></p>
  
  <p>because a <strong>Set</strong> does not allow duplicate values, if so what would be the possible approach.</p>