title: How to fetch single row in one to many mapping using hibernate criteria
body: <pre><code>@Entity
  @Table(name = "test")
  public class A {
  
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "ID")
     private int    id;
  
     @OneToMany(fetch = FetchType.EAGER)
     @JoinColumn(name = "B_ID")
     private List&lt;B&gt; details;
     ......
  }
  
  @Entity
  @Table(name = "test1")
  public class B {
  
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "ID")
     private int    id;
  
     @Column(name = "NAME")
     private String name;
     ......
  }
  </code></pre>
  
  <p><strong>Criteria</strong> </p>
  
  <pre><code>Criteria criteria = session.createCriteria(A.class)
                  .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
                  .add(Restrictions.in(id, list))
  List = criteria.list();
  </code></pre>
  
  <p>As there are many matching rows with id "1" I would get below result. But I need only first one</p>
  
  <p><strong>Result :</strong> </p>
  
  <pre><code>{
    "id":1,
    "details":[
       {
          "name":abc,
       },
       {
          "name":123,
       },
       {
          "name":xyz,
       },
   }
  </code></pre>
  
  <p><strong>Trying to get result as below : Only first row instead of all the rows from test1 table (B.class)</strong> </p>
  
  <pre><code> {
    "id":1,
    "details":[
       {
          "name":abc,
       }
   }
  </code></pre>
  
  <p>I am using hibernate criteria to fetch results. I want to limit the data retrieved from joined table (one to many mapping). Is this possible?</p>
  
  <p>Please let me know how to achieve this.</p>