I\'ve been trying for the this whole a query who is officially giving me nightmares. The system is a user and contact management. So I have UserAccount
, Conta
HQL query would be probably something along these lines:
select c from Contact c join c.phones cphones where c.userAccount.email = :email and cphones.formatedNumber = :number
Also you may want to handle results of query like this. The list() method returns always a list, never a null.
return !result.isEmpty();