title: Error: org.hibernate.exception.SQLGrammarException: could not extract ResultSet and dateAccessed is unknown column
body: <p>I am executing below query in spring MVC JAVA</p>
  
  <pre><code>if (currentFireTime != null &amp;&amp; previousFireTime != null) {
          timePart = " sal.dateAccessed between '" + previousFireTime + "' and '" + currentFireTime + "' and ";
      }
      String queryString = " select count(*) as COUNT FROM LogData sal where " + timePart + " sal.userSigned = false and sal.batchMetaDataId = "+batchId;
      SQLQuery sq =sessionFactory.getCurrentSession().createSQLQuery(queryString);
      sq.addScalar("COUNT", IntegerType.INSTANCE);
      sq.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
      List&lt;Map&lt;String,Object&gt;&gt; resultSet=sq.list();
      return (Integer)resultSet.get(0).get("COUNT");
  </code></pre>
  
  <p>When executed looks like this and putting this in Mysql it works fine. But i get error as shown below.  </p>
  
  <pre><code>select count(*) as COUNT FROM LogData sal where sal.dateAccessed between '2016-12-26 00:00:00.618' and '2016-12-26 01:00:00.618' and  sal.userSigned = false and sal.batchMetaDataId = 86
  </code></pre>
  
  <p>error shown </p>
  
  <pre><code>    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
  at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
  at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
  at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
  </code></pre>
  
  <p>What should i need to change in shown code?</p>