title: Invalid Column Name error with Hibernate createSQLquery
body: <p>This is a smaller version of a larger query I'm trying to get working. When I run the query I get the following error. I've tried removing as much of the query as I can to try to find the guilty column, but haven't had any success.
  I'm using Spring 3.2.1, Hibernate 3.6, and Oracle 11g</p>
  
  <pre><code>Caused by: java.sql.SQLException: Invalid column name
      at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3711)
      at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2763)
      at oracle.jdbc.driver.OracleResultSet.getBigDecimal(OracleResultSet.java:368)
      at org.hibernate.type.descriptor.sql.DecimalTypeDescriptor$2.doExtract(DecimalTypeDescriptor.java:62)
      at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>String query = "SELECT d.ID as {d.id}, d.DETAIL_ORDER as {d.detailOrder}, g.ID as {g.id}, g.NAME as {g.name} " +
      "FROM EVAL_MASTER_EVAL_DETAIL d " +
      "JOIN EVAL_QUESTION_GROUP g ON d.GROUP_ID = g.ID " +
      "WHERE d.ACTIVE = 'Y' " +
      "AND d.MASTER_EVAL_ID =  :evalId" + 
      " ORDER BY d.DETAIL_ORDER ASC"; 
  
      details = session.createSQLQuery(query).addEntity("d", EvalMasterEvalDetail.class)
      .addEntity("g", EvalQuestionGroup.class).setParameter("evalId", evalId).list();
  </code></pre>
  
  <p>Resulting Hibernate Query:</p>
  
  <pre><code>Hibernate: SELECT d.ID as ID29_0_, d.DETAIL_ORDER as DETAIL5_29_0_, g.ID as ID34_1_, g.NAME as NAME34_1_ FROM EVAL_MASTER_EVAL_DETAIL d JOIN EVAL_QUESTION_GROUP g ON d.GROUP_ID = g.ID WHERE d.ACTIVE = 'Y' AND d.MASTER_EVAL_ID =  ? ORDER BY d.DETAIL_ORDER ASC
  </code></pre>
  
  <p>Mappings (to verify names)</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
          &lt;class name="org.anes.surveys.domain.EvalMasterEvalDetail" table="EVAL_MASTER_EVAL_DETAIL"&gt;
              &lt;id name="id" type="big_decimal"&gt;
                  &lt;column name="ID" precision="22" scale="0" /&gt;
                  &lt;generator class="sequence-identity" &gt;
                      &lt;param name="sequence"&gt;EVAL_MASTER_EVAL_DETAIL_SEQ&lt;/param&gt;
                  &lt;/generator&gt;
              &lt;/id&gt;
              &lt;many-to-one name="evalQuestionGroup" class="org.anes.surveys.domain.EvalQuestionGroup" fetch="select"&gt;
                  &lt;column name="GROUP_ID" precision="22" scale="0" /&gt;
              &lt;/many-to-one&gt;
          &lt;many-to-one name="evalMasterEvaluation" class="org.anes.surveys.domain.EvalMasterEvaluation" fetch="select"&gt;
          &lt;column name="MASTER_EVAL_ID" precision="22" scale="0" not-null="true" /&gt;
      &lt;/many-to-one&gt;
              &lt;property name="detailOrder" type="big_decimal"&gt;
                  &lt;column name="DETAIL_ORDER" precision="22" scale="0" not-null="true" /&gt;
              &lt;/property&gt;
              &lt;property name="active" type="string"&gt;
                  &lt;column name="ACTIVE" length="1" not-null="true" /&gt;
              &lt;/property&gt;
          &lt;/class&gt;
      &lt;/hibernate-mapping&gt;
  
  &lt;hibernate-mapping&gt;
      &lt;class name="org.anes.surveys.domain.EvalQuestionGroup" table="EVAL_QUESTION_GROUP"&gt;
          &lt;id name="id" type="big_decimal"&gt;
              &lt;column name="ID" precision="22" scale="0" /&gt;
              &lt;generator class="sequence-identity" &gt;
                  &lt;param name="sequence"&gt;EVAL_QUESTION_GROUP_SEQ&lt;/param&gt;
              &lt;/generator&gt;
          &lt;/id&gt;
          &lt;property name="name" type="string"&gt;
              &lt;column name="NAME" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;set name="evalMasterEvalDetails" table="EVAL_MASTER_EVAL_DETAIL" inverse="true" lazy="true" fetch="select"&gt;
              &lt;key&gt;
                  &lt;column name="GROUP_ID" precision="22" scale="0" /&gt;
              &lt;/key&gt;
              &lt;one-to-many class="org.anes.surveys.domain.EvalMasterEvalDetail" /&gt;
          &lt;/set&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>EDIT:
  Tried the following and still get invalid column error. ACTIVE &amp; d.active are strings.</p>
  
  <pre><code>String query = "SELECT ACTIVE as {d.active} " +
                  "FROM EVAL_MASTER_EVAL_DETAIL";
  details = session.createSQLQuery(query).addEntity("d", EvalMasterEvalDetail.class).list();
  
  String query = "SELECT d.ID " +
          "FROM EVAL_MASTER_EVAL_DETAIL d ";
  details = session.createSQLQuery(query).addEntity("d", EvalMasterEvalDetail.class).list();
  
  String query = "SELECT ID " +
          "FROM EVAL_MASTER_EVAL_DETAIL";
  details = session.createSQLQuery(query).addEntity("d", EvalMasterEvalDetail.class).list();
  </code></pre>
  
  <p>This works, but I only get scalar values:</p>
  
  <pre><code>String query = "SELECT ID " +
          "FROM EVAL_MASTER_EVAL_DETAIL";
  details = session.createSQLQuery(query).list();
  </code></pre>