So, I have the following query below:
public Iterable<Dealer> findAll(Dealer dealer) { QDealer qdealer = QDealer.dealer; BooleanExpression where = null; if(dealer.getId() != null && dealer.getId() != 0) { buildPredicate(qdealer.id.goe(dealer.getId())); } OrderSpecifier<String> sortOrder = QDealer.dealer.dealerCode.desc(); Iterable<Dealer> results = dlrRpstry.findAll(where, sortOrder); return results; }
The above query is working fine. However, I would like to first sort the results by type dealerType, and then by the dealer code something like βorder by type of dealers asc, dealCode descβ. How to create an instance of OrderSpecifier so that the results are sorted by dealer type, and then by dealer code.
DealerRepository dlrRpstry extends JpaRepository, QueryDslPredicateExecutor
I use spring -data-jpa-1.1.0, spring -data-commons-dist-1.3.2 and querydsl-jpa-2.9.0.
If the OrderSpecifier cannot be configured to sort multiple columns, what would be an alternative solution that would satisfy my requirement to sort the results βby type of dealer asc, dealCode descβ.
Any help would be greatly appreciated. Thanks in advance.
Nick
source share