在 JPQL 中,我想构造与此等效的查询:
select *, count(*) as finger_count from page_delta_summary
where delta_history_id = ? and change_type = ? group by fingerprint;
fingerprint
table 中的 varchar 字段在哪里page_delta_summary
。我所拥有的是:
select d, count(d) as finger_count from PageDeltaSummary d
where d.deltaHistoryId = :deltaHistoryId and d.type = :pageDeltaType
GROUP BY d.fingerprint"
PageDeltaSummary
我的实体在哪里。但我得到以下异常:
org.apache.openjpa.persistence.ArgumentException:您对类型“com.su3analytics.sitedelta.model.PageDeltaSummary”的查询,过滤器“select d, count(d) from PageDeltaSummary d where d.deltaHistoryId = :deltaHistoryId and d.type = :pageDeltaType GROUP BY d.fingerprint" 无效。 您的 select 和 having 子句必须仅包含也出现在您的分组子句中的聚合或值。
如果我将 count(d) 删除为 finger_count 或 GROUP BY,则查询工作正常。
有什么建议么?
谢谢