You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Moritz Becker (JIRA)" <ji...@apache.org> on 2017/11/12 14:20:00 UTC
[jira] [Commented] (DELTASPIKE-1247) Orderby clause added to count
query
[ https://issues.apache.org/jira/browse/DELTASPIKE-1247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16248871#comment-16248871 ]
Moritz Becker commented on DELTASPIKE-1247:
-------------------------------------------
A PR with a fix will follow shortly.
> Orderby clause added to count query
> -----------------------------------
>
> Key: DELTASPIKE-1247
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-1247
> Project: DeltaSpike
> Issue Type: Bug
> Components: Data-Module
> Affects Versions: 1.7.2
> Reporter: Mustafa Makebits
> Priority: Minor
>
> I have the following repository code:
> {code:title=PurchaseRequisitionRepository.java|borderStyle=solid}
> @Repository
> public interface PurchaseRequisitionRepository extends EntityRepository<PurchaseRequisition, String>, Serializable {
> @Query("select e from PurchaseRequisition e")
> QueryResult<PurchaseRequisition> findAllPurchaseRequisitions();
> }
> {code}
> And in my service code I'm trying to set the sort order like so:
> {code}
> repository.findAllPurchaseRequisitions().withPageSize(pageSize).orderDesc("prrId", false);
> {code}
> At some point I do query.countPages() or some thing similar, which causes this sql to be generated:
> {code}
> select
> count(purchasere0_.id) as col_0_0_
> from
> omis_db.purch_requisition purchasere0_
> order by
> purchasere0_.id limit ?
> {code}
> which in turn cause a sql exception:
> {quote}
> org.hibernate.exception.SQLGrammarException: ERROR: column "purchasere0_.id" must appear in the GROUP BY clause or be used in an aggregate function
> Position: 96
> {quote}
> Am I doing anything wrong to cause this behavior? is there a way to work around it so that I can set the order and do paging at the same time?
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)