title: HQL createQuery throws NullPointerException when create new object in query
body: <p>I am trying to create new object from the result set of HQL query but it is throwing NullPointerException at <code>session.createQuery()</code> </p>
  
  <p>Could someone please show me any flaw in the query that I created?</p>
  
  <p>The idea is to return the <code>type/area/reason</code> along with their <code>count</code> and then create new <code>CasesOverview</code> object with these values.</p>
  
  <pre><code>        StringBuilder hql = new StringBuilder("SELECT NEW CasesOverviewDTO(:filterColumnString, Math.toIntExact(count(c.id)), :filter) ");
          hql.append("FROM Case AS c ");
          hql.append("where c.site.id = :siteId and c.status ");
          if(isOpen) {
              hql.append("!= :close and createdDate &gt; :startDate and createdDate &lt; :endDate ");
          } else {
              hql.append("= :close and closedDate &gt; :startDate and closedDate &lt; :endDate ");
          }
          hql.append("group by :filterColumn");
  
          Query query = exeQuery(hql.toString());
          switch(filter) {
              case TYPE:
                  query.setParameter("filterColumnString", "c.area.toString()");
                  query.setParameter("filterColumn", "c.area");
                  break;
              case CASE_TYPE:
                  query.setParameter("filterColumnString", "c.type.toString()");
                  query.setParameter("filterColumn", "c.type");
                  break;
              case RESOLUTION:
                  query.setParameter("filterColumnString", "c.reason.toString()");
                  query.setParameter("filterColumn", "c.reason");
                  break;
          }
          query.setParameter("filter", filter);
          query.setParameter("siteId", siteId);
          query.setParameter("close", "CLOSED");
          query.setParameter("startDate", startDate);
          query.setParameter("endDate", endDate);
  </code></pre>
  
  <p>In the <code>createQuery</code> method, error is thrown:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
  at org.hibernate.hql.internal.ast.tree.ConstructorNode.formatMissingContructorExceptionMessage(ConstructorNode.java:201)
  at org.hibernate.hql.internal.ast.tree.ConstructorNode.resolveConstructor(ConstructorNode.java:193)
  at org.hibernate.hql.internal.ast.tree.ConstructorNode.prepare(ConstructorNode.java:158)
  at org.hibernate.hql.internal.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:1095)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2328)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:2194)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1476)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:573)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249)
  at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278)
  at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
  at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
  at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:126)
  at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:88)
  at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
  at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
  at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
  at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
  at com.essensys.bluefin.dao.hibernate.HibernateGenericDao.exeQuery(HibernateGenericDao.java:411)
  </code></pre>