SQL : Intuitive way for count(*)

Reported by Samppa Saarela on 2010-09-08
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Medium
Samppa Saarela

Bug Description

Using count(*) in searches is a very common case but in querydsl it's still quite unintuitive. Could there be a shortcut for it?

E.g.

query.list(query.all().count());

or

query.list(SQLCommonQuery.ALL.count());

summary: - Intuitive way for count(*)
+ SQL : Intuitive way for count(*)
Changed in querydsl:
importance: Undecided → Medium
Samppa Saarela (samppa-saarela) wrote :

Wildcard can now be used through Wildcard class:

@Test
public void wildcardAll() {
    expectedQuery = "select * from EMPLOYEE2 e";
    query().from(employee).uniqueResult(Wildcard.all);
}

@Test
public void countAll() {
    expectedQuery = "select count(*) as rowCount from EMPLOYEE2 e";
    PNumber<Long> rowCount = new PNumber<Long>(Long.class, "rowCount");
    query().from(employee).uniqueResult(Wildcard.count().as(rowCount));
}

Changed in querydsl:
status: New → Fix Committed
assignee: nobody → Samppa Saarela (samppa-saarela)

Released in 1.9.6

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers