HQL with a collection in the WHERE clause

后端 未结 1 1878
情话喂你
情话喂你 2021-02-20 05:21

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

1条回答
  •  佛祖请我去吃肉
    2021-02-20 05:29

    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();
    

    0 讨论(0)
提交回复
热议问题