Subquery<A> subquery = criteriaQuery.subquery(A.class);
Root<A> root1 = subquery.from(A.class);
subquery = subquery.select(root1.get("attrx"));
subquery = subquery.where(criteriaBuilder.and(
criteriaBuilder.equal(root1.get("attr1"), root.get("attr11")),
criteriaBuilder.equal(root1.get("attr2"), "value")
));
criteriaBuilder.exists(subquery)