Reputation: 327
What's so wrong with the following QueryDSL code:
query.from(chat).where(
chat.datePosted.goe(startDate.atStartOfDay()).
and(chat.datePosted.lt(endDate.plusDays(1).atStartOfDay()))).
groupBy(date(chat.datePosted)).
list(date(chat.datePosted), date(chat.datePosted).count());
that I get an exception like this:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 1, column 41 [select date(chat.datePosted), count(date(chat.datePosted))
from com.test.model.Chat chat
where chat.datePosted >= ?1 and chat.datePosted < ?2
group by date(chat.datePosted)]
?
I'm using Spring Boot 1.3.6 and QueryDSL 3.7.4 (JPA via Hibernate).
Upvotes: 2
Views: 3732
Reputation: 327
Refuse as I may it looks like using functions as arguments in hibernate aggregation functions is prohibited, eg.: count(date(field)) doesn't work with Hibernate. What a bummer!
Simply removing any call to another function under count() did the trick in my case because the results are the same. Seems like a Hibernate implementation issue since Timo mentions on the related question that this works under EclipseLink.
Upvotes: 3