currently distinct only works on last level of query

Bug #691930 reported by KBachl on 2010-12-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Medium
Timo Westkämper

Bug Description

currently if one has a JPQL query = new JPAQuery(em).from(base); he can only use distinct on the last level as the query then is at its end as

query.countDistinct() - query ends in long (no arg, he takes in the base as distinct)
query.iterateDistinct(..) - query ends in Iterator
query.listDistinct(...) - same as above in List

wich is quite a problem if you pass around the query and reuse it for e.g.: multiple calls; For example I first need to do a countDistinct to the DB to afterwards do a range based list pull - it would be easy if we had a
query.distinct() method (maybe even .distinct(QEntityPath from)?) that comes from base and returns a JPQLQuery so at any time one can trigger it;

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

Sorry, I didn't have time to implement this for the 2.0.7 release, but it will be in the next one.

Added the following methods :

public interface Query<Q extends Query<Q>> extends FilteredClause<Q>{
    /**
     * Set the Query to return distinct results
     *
     * @return
     */
    Q distinct();

}

public interface SimpleQuery<Q extends SimpleQuery<Q>> extends FilteredClause<Q>{
    /**
     * Set the Query to return distinct results
     *
     * @return
     */
    Q distinct();
}

Changed in querydsl:
status: New → Fix Committed

Released in 2.0.8

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