Could you try with subquery.select( criteriaBuilder.literal(1) ); to make sure the parenthesis of the embedded id is not problematic?