[
https://issues.apache.org/jira/browse/DELTASPIKE-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14127997#comment-14127997
]
chunlinyao commented on DELTASPIKE-714:
---------------------------------------
Maybe this count query will work.
{{Select count(counte) from Entity counte where counte in (<original jpql>)}}
original jpql is select e from Entity e where ... order by ...
the origin jpql can contains order by or other things.
> QueryResult.count not work if jpql have order by
> ---------------------------------------------------
>
> Key: DELTASPIKE-714
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-714
> Project: DeltaSpike
> Issue Type: Bug
> Components: Data-Module
> Affects Versions: 1.0.2
> Reporter: chunlinyao
>
> I have a entity which have a field scannedDate, create a repository with
> method findByXXX() which return a QueryResult.
> If I call QueryResult.orderAsc("scannedDate").count(), this error will
> happen.
> ERROR: column "t0.scanneddate" must appear in the GROUP BY clause or be used
> in an aggregate function
> I use openjpa 2.2, We cannot simply remove the "order by", Because if we
> order by a attribute of associated entity like order by e.foo.bar, JPA engine
> will generate a inner join, if we simply remove the "order by" the count
> result will not correct.
> Maybe this is not a bug, just a limitation.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)