title: How can I use the sql case clause in HQL?
body: <p>I really need help regarding this one. </p>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>  hSql=" select case 
        when min(start_day_plan) is not NULL then min(start_day_plan)
        else to_date((min(insertDate)) - cast('1 month' as interval),'yyyy-MM-dd' )
        end 
        from Project"
  
      getHibernateTemplate().find(hSql);
  </code></pre>
  
  <p>But this generates the error below:</p>
  
  <hr>
  
  <pre><code>java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.CaseNode 
   \-[CASE] CaseNode: 'case'
      +-[WHEN] SqlNode: 'when'
      |  +-[IS_NOT_NULL] UnaryLogicOperatorNode: 'is not null'
      |  |  \-[AGGREGATE] AggregateNode: 'min'
      |  |     \-[IDENT] IdentNode: 'start_day_plan' {originalText=start_day_plan}
      |  \-[AGGREGATE] AggregateNode: 'min'
      |     \-[IDENT] IdentNode: 'start_day_plan' {originalText=start_day_plan}
      \-[ELSE] SqlNode: 'else'
         \-[METHOD_CALL] MethodNode: '('
            +-[METHOD_NAME] IdentNode: 'to_date' {originalText=to_date}
            \-[EXPR_LIST] SqlNode: 'exprList'
               +-[MINUS] BinaryArithmeticOperatorNode: '-' {dataType=org.hibernate.type.DoubleType@bb21ab}
               |  +-[AGGREGATE] AggregateNode: 'min'
               |  |  \-[IDENT] IdentNode: 'insertDate' {originalText=insertDate}
               |  \-[METHOD_CALL] MethodNode: '('
               |     +-[METHOD_NAME] IdentNode: 'cast' {originalText=cast}
               |     \-[EXPR_LIST] SqlNode: 'exprList'
               |        +-[QUOTED_STRING] LiteralNode: ''1 month''
               |        \-[IDENT] IdentNode: 'interval' {originalText=interval}
               \-[QUOTED_STRING] LiteralNode: ''yyyy-MM-dd''
  </code></pre>
  
  <p>what will be the correct query for this? im just trying to subtract 1 month from the insertdate.</p>
  
  <p>If you could help, please do so..thanks :)</p>
  
  <p></p>