SQL : UNION with ORDER BY fails

Bug #837903 reported by Timo Westkämper on 2011-08-31
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

ListSubQuery<String> firstSQ = new SQLSubQuery().from(QTable.table).list(QTable.table.name);
ListSubQuery<String> secondSQ = new SQLSubQuery().from(QOtherTable.otherTable).list(QOtherTable.otherTable.name);
List<String> names = new SQLQueryImpl(connection, templates)
    .union(firstSQ, secondSQ)
    .orderBy(...)
    .list();

I have tried following options:

    .orderBy(QTable.table.name.asc())
    .orderBy(QOtherTable.otherTable.name.asc())

but both lead me to an exception:

Exception in thread "main" java.lang.IllegalArgumentException: Undeclared path other_table
        at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:48)
        at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
        at com.mysema.query.types.path.StringPath.accept(StringPath.java:43)
        at com.mysema.query.DefaultQueryMetadata.validate(DefaultQueryMetadata.java:296)
        at com.mysema.query.DefaultQueryMetadata.addOrderBy(DefaultQueryMetadata.java:123)
        at com.mysema.query.support.QueryMixin.orderBy(QueryMixin.java:307)
        at com.mysema.query.support.QueryBase.orderBy(QueryBase.java:40)
        at com.mysema.query.sql.AbstractSQLQuery$UnionBuilder.orderBy(AbstractSQLQuery.java:78)

Changed in querydsl:
status: New → Fix Committed

Released in 2.2.2

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