QueryDSL (JPA) dayOfYear, dayOfMonth translation to hibernate

ぃ、小莉子 提交于 2020-02-05 08:44:11

问题


I'm getting an exception when running this java code:

List<Tuple> companies2accLoginCount = accoutLoginCountQuery
                    .listDistinct(new QTuple(QCompany.company1.id, QAccountLogin.accountLogin.loginDatetime.dayOfMonth().countDistinct()));

The exception:

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 1, column 48 [select distinct company1.id, count(distinct day(accountLogin.loginDatetime))
from de.workxl.cxlbackend.database.model.Company company1
  left join company1.accounts as account
  left join account.accountLogins as accountLogin
where accountLogin.loginDatetime > ?1
group by company1.id
having count(distinct day(accountLogin.loginDatetime)) >= ?2]

The same with dayofyear. It seems something else than a left bracket is expected after dayofyear or dayofmonth.

I'm using Hibernate 4.2.2 and QueryDSL 2.9.0

update: I've just managed to migrate the project to QueryDSL 3.2.3 (had to upgrade spring-data-commons to 1.6.1 and spring-data-jpa to 1.4.1 as well) but the exception persists.


回答1:


This seems to be a bug in Hibernate's parser. This works with EclipseLink.



来源:https://stackoverflow.com/questions/18984611/querydsl-jpa-dayofyear-dayofmonth-translation-to-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!