Having a situation where my java code is symbolic to query -
SELECT CUSTOMER_ID,
CUSTOMER_NAME,
CASE
WHEN COUNT (DISTINCT CARD_ID
I faced a similar situation...
query.multiselect(root, computedColumn);
query.orderBy(new Order[]{filterDTO.getSortAsc() ? cb.asc(cb.literal(2)) : cb.desc(cb.literal(2))});
I my case computedColumn is Subquery...I did not manage to make it work by column alias but it seems to work by column index returned in the tupple so I guess in your code it should work by index 1
query.orderBy(cb.asc(cb.literal(1)));