问题
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