Using the Criteria API the statement sent to the database has a syntax error because of left parenthesis between keywords "and" and "exists".
Wildfly 10.1., Oracle 11 database
Could you try with subquery.select( criteriaBuilder.literal(1) ); to make sure the parenthesis of the embedded id is not problematic?
Indeed, replacing the selecting of the compound primary key fields by selecting constant value 1 does solve problem.
I'm quite sure I tested this before changing the genrated SQL query by hand when I created the question in the forum.