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:
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"
Unluckily, the only one millisec will make a huge difference, thus plain group by o.timeOfOrder doesn't work.
I have tried this approach, however I've got
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.
Perhaps, there are any another way out except changing the type of field in DB?