![](/img/trans.png)
[英]What is the JPQL equivalent of the PostgreSQL date_trunc('day', (entity.date AT TIME ZONE 'UTC')) function when using JPA and Hibernate
[英]date_trunc function in jpql query
我真的被 JPQL 中的 date_trunc 函數困住了。
我的查詢是:
@Query("SELECT c.name AS name, SUM(c.salary) AS salary FROM SalaryTable AS c GROUP BY c.name, date_trunc('year' c.savedtimestamp)")
我得到了例外:
有 'date_trunc' 和 '('year' c.savedtimestamp)' 沒有用逗號分隔。\n[197, 203] 標識變量 ''year'' 不遵循 ZD52387880E1EA22817A72D375921381 標識符的規則。", "\tat org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:157)","\tat org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java: 336)","\tat org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:280)","\tat
你能在這方面幫助我嗎?
問候,斯蒂芬
應該:
date_trunc('year', c.savedtimestamp)
請注意錯誤消息中的“,”
has 'date_trunc' and '('year' c.savedtimestamp)' that are not separated by a comma
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.