Shortcut for Expr.as(Path)

Bug #633128 reported by Samppa Saarela on 2010-09-08
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Medium
Timo Westkämper

Bug Description

Instead of

PNumber<Long> countAlias = new PNumber<Long>(Long.class, "rowCount");
// ...use countAlias in e.g. having clause...
query.list(entity.column.count().as(countAlias));

Something like this:

ENumber<Long> count = entity.column.count().as("count");
// ...use count in e.g. having clause...
query.list(count);

In this latter form "count" would be serialized in full form in select and from clauses and through the alias in other query parts.

Changed in querydsl:
importance: Undecided → Medium
Changed in querydsl:
assignee: nobody → Timo Westkämper (timo-westkamper)
status: New → In Progress

Added shortcut into ESimple and subclasses. Usage examples :

    @Test
    @ExcludeIn({DERBY,HSQLDB})
    public void path_alias(){
        expectedQuery = "select e.LASTNAME, sum(e.SALARY) as salarySum from EMPLOYEE2 e group by e.LASTNAME having salarySum > ?";

        ENumber<BigDecimal> salarySum = employee.salary.sum().as("salarySum");
        query().from(employee)
        .groupBy(employee.lastname)
        .having(salarySum.gt(10000))
        .list(employee.lastname, salarySum);
    }

The alias is serialized in full form in select and from parts and in short form everywhere else

Changed in querydsl:
status: In Progress → Fix Committed

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