2016-09-15 5 views
1

:私は「QueryDSL:見つけ、CLOSE期待 '(' 次QueryDSLコードでそう間違って何

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)] 

:?私はこのような例外を取得

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()); 

Springブート1.3.6とQueryDSL 3.7.4(JPA by Hibernate)を使用しています。

+0

[この質問](http://stackoverflow.com/questions/18984611/querydsl-jpa-dayofyear-dayofmonth-translation-to-hibernate)に関連しているようですが、私は休止状態でこのような単純なクエリを解析することはできません。 –

+0

問題はendDate.plusDays(1).atStartOfDay()にあるようです - まずその値を計算してから値を渡してみてください。 –

+0

DATEは有効なJPQL関数ではありません。どんなJPQLリファレンスもこれを伝えるでしょう –

答えて

2

using functions as arguments in hibernate aggregation functionsは禁止されています。例:count(date(field))はHibernateでは動作しません。なんとバマー!

count()の下の別の関数への呼び出しを削除するだけで、結果が同じであるため私の場合はやりとりができませんでした。 TimoはこれがEclipseLinkで動作するという関連する質問について言及して以来、Hibernate実装の問題のようです。