Having a situation where my java code is symbolic to query -
SELECT CUSTOMER_ID, CUSTOMER_NAME, CASE WHEN COUNT (DISTINCT CARD_ID
It seems this is not possible with the JPA Criteria API and you will have to fallback to using JPQL/HQL instead.