title: QueryDsl - case expression with string value
body: <p>QueryDsl 3.3.4<br>
  Hibernate 3.6.10-Final
  I have two entities:</p>
  
  <pre><code>public class Document {
      private Confirmation confirmation;
  }
  
  public class Confirmation {
      ...
  }
  </code></pre>
  
  <p>I need a query like this:</p>
  
  <pre><code>SELECT count(d.id), CASE WHEN d.confirmation_id IS NULL then 'NOT_CONFIRMED' else 'CONFIRMED' END as confirmed FROM document d GROUP BY confirmed;
  </code></pre>
  
  <p>So it should be grouped by the result of case expression above.<br>
  Now, to translate the case part to querydsl:</p>
  
  <pre><code>StringExpression confirmExp = new CaseBuilder()
      .when(Expressions.booleanTemplate("confirmation_id is null"))
      .then(Expressions.stringTemplate("NOT_CONFIRMED"))
      .otherwise(Expressions.stringTemplate("CONFIRMED"));
  </code></pre>
  
  <p>I'm using <code>.when(Expressions.booleanTemplate("confirmation_id is null"))</code> to avoid joining on <code>confirmation</code> table.
  Running the query with such expression I'm getting an exception below.<br>
  Is this another hibernate bug or such case needs to be differently?</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: No data type for node: >org.hibernate.hql.ast.tree.CaseNode 
    +-[CASE] CaseNode: 'case'
    |  +-[WHEN] SqlNode: 'when'
    |  |  +-[IS_NULL] IsNullLogicOperatorNode: 'is null'
    |  |  |  -[IDENT] IdentNode: 'confirmation_id' {originalText=confirmation_id}
    |  |  -[IDENT] IdentNode: 'NOT_CONFIRMED' {originalText=NOT_CONFIRMED}
    |  -[ELSE] SqlNode: 'else'
    |     -[IDENT] IdentNode: 'CONFIRMED' {originalText=CONFIRMED}</p>
    
    <blockquote>
      <p>org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:156)</p>
    </blockquote>
  </blockquote>