DomainObject emp = q1.addRoot(Employee.class);
QueryDefinition q2 = qb.createQueryDefinition();
DomainObject spouseEmp = q2.addRoot(Employee.class);
q2.where(spouseEmp.equal(emp.get("spouse"))).select(spouseEmp);
q1.selectDistinct(emp).where(q2.exists());
String jpql = "SELECT DISTINCT e "
+ " FROM Employee e"
+ " WHERE EXISTS ("