title: Hibernate Criteria ResultTransformer - bean with List / Set inside
body: <p>I have entity like this:</p>
  
  <pre><code>public class EntityClass{
      private String id;
      private String name;
      private List&lt;OtherEntityClass&gt; others;
  }
  </code></pre>
  
  <p>and bean class like this: </p>
  
  <pre><code>public class BeanClass{
      private String id;
      private String name;
      private Set&lt;Long&gt; ids;
  } 
  </code></pre>
  
  <p>and i try to get result (<code>List&lt;BeanClass&gt;</code>) using following criteria:</p>
  
  <pre><code>Criteria criteria = session.createCriteria(EntityClass.class)
      .createAlias("others", "others", JoinType.LEFT_OUTER_JOIN)
      .setProjection(Projections.projectionList()
          .add(Projections.property("id"), "id")                   // this is OK
          .add(Projections.property("name"), "name")               // this is OK
          .add(Projections.property("others.id"), "others"))       // there is problem
      .setResultTransformer(Transformers.aliasToBean(BeanClass.class));
  
  List&lt;BeanClass&gt; result = criteria.list();
  </code></pre>
  
  <p>Problem is (i think) in way how hibernate giving tuples into Tranformer. 
  In class <a href="http://www.atetric.com/atetric/javadoc/org.hibernate/hibernate-core/4.2.10.Final/org/hibernate/transform/AliasToBeanResultTransformer.html" rel="nofollow">AliasToBeanResultTransformer</a> i found method:</p>
  
  <pre><code>public Object transformTuple(Object[] tuple, String[] aliases);
  </code></pre>
  
  <p>Hibernate is "giving" into tuples rows / arrays like this (method is executed 4 times):</p>
  
  <p>1st invocation</p>
  
  <ul>
  <li>1</li>
  <li>sameName </li>
  <li>23</li>
  </ul>
  
  <p>2nd invocation</p>
  
  <ul>
  <li>1</li>
  <li>sameName </li>
  <li>24</li>
  </ul>
  
  <p>3rd invocation</p>
  
  <ul>
  <li>1</li>
  <li>sameName </li>
  <li>26</li>
  </ul>
  
  <p>4th invocation</p>
  
  <ul>
  <li>1</li>
  <li>sameName </li>
  <li>27</li>
  </ul>
  
  <p>I would like it "give" there (in only 1 invocation):</p>
  
  <ul>
  <li>1</li>
  <li>sameName </li>
  <li>[23,24,26,27] </li>
  </ul>
  
  <p>Have someone solution for my ? </p>
  
  <hr>
  
  <p>I was created temporary workaround, but it is really ugly. (<a href="http://pastebin.com/Zj4ScdaV" rel="nofollow">My Own Transformer</a>)</p>