title: Group by timestamp in jpql with JPA
body: <p>guys!
  I'm trying to group query results by timestamp in JPQL using JPA (EclipseLink + Derby) and use them for creating a Result object. 
  My query is:</p>
  
  <pre><code>Select new com.restaurant.entities.Report(o.timeOfOrder, count(o.id), sum(o.price))";
      queryText+=" from Orders o ";
      queryText+="where o.timeOfOrder BETWEEN :start AND :end";
      queryText+=" group by o.timeOfOrder"
  </code></pre>
  
  <p>Unluckily, the only one millisec will make a huge difference, thus plain group by o.timeOfOrder doesn't work.</p>
  
  <p>I have tried <a href="https://stackoverflow.com/questions/25512501/jpql-group-by-timestamp-as-a-date">this approach</a>, however I've got </p>
  
  <pre><code>Internal Exception: java.sql.SQLSyntaxErrorException: Column reference 'ORDERS.TIMEOFORDER' is invalid, or is part of an invalid expression.  For a SELECT list with a GROUP BY, the columns and expressions being selected may only contain valid grouping expressions and valid aggregate expressions.
  </code></pre>
  
  <p>Perhaps, there are any another way out except changing the type of field in DB?</p>