title: Hibernate-generated column aliases break AliasToBeanResultTransformer when using query
body: <p>What I am trying to achieve is to set a result transformer on a query defined in the following way:</p>
  
  <pre><code>String hqlQueryString = "select o.id as id, o.name as objectName from MyObject"; 
  Class resultClass = MyObject.class;
  Query query = session.createQuery(hqlQueryString).setResultTransformer(
          new new AliasToBeanResultTransformer(resultClass));
  List result = query.list();
  </code></pre>
  
  <p>MyObject looks like this:   </p>
  
  <pre><code>public class MyObject {
      private int id;
      private String objectName;
  
      public int getId() {
          return id;
      }
      public void setId(int value) {
          this.id = value;
      }
  
      public String getObjectName() {
          return objectName;
      }
      public void setobjectName(String value) {
          this.objectName = value;
      }
  }
  </code></pre>
  
  <p>The problem is, that although I have specified <code>id</code> and <code>objectName</code> to be my aliases, the actual query being executed uses different aliases. This causes my <code>AliasToBeanResultTransformer</code> to fail to construct <code>MyObject</code> because the aliases do not match property names. </p>
  
  <p>Is it possible to obtain the aliases of the query generated by hibernate programmatically (I can set them to the alias to bean result tranformer)? I tried using <code>query.getReturnAliases()</code> but it returns the aliases that I have defined in my HQL, not the ones that Hibernate actually uses.</p>
  
  <p>Can I explicitly specify the aliases in a <code>createQuery</code> statement? Currently I am trying not to use criterion for this to work, so I'd appreciate an approach that uses query objects, if such exists.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Although the issue described above is invalid for standard HQL queries (see comments), it is valid when executing a native query. To be specific - native queries seemed to treat all aliases as lowecase strings (despite specific capitalization that might have been introduced in the query). This causes the <code>AliasToBeanResultTransformer</code> to fail when setting the properties, in cases where capitalization matters.</p>