Setting a parameter as a list for an IN expression

前端 未结 9 2514
北荒
北荒 2020-11-30 07:14

Whenever I try to set a list as a parameter for use in an IN expression I get an Illegal argument exception. Various posts on the internet seem to indicate that this is poss

9条回答
  •  心在旅途
    2020-11-30 08:08

    Use NamedQuery instead:

    List logins = em.createNamedQuery("Account.findByIdList").setParameter("ids", Arrays.asList(new Long(1000100), new Long(1000110))).getResultList();
    

    Add the named query to your entity

    @NamedQuery(name = "Account.findByIdList", query = "SELECT a.accountManager.loginName FROM Account a WHERE a.id IN :ids")
    

提交回复
热议问题