Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd 2 list in parameter in JPA using In Query
    primarykey
    data
    text
    <p>I want to pass two list in <strong>jpa query with tuple using IN query</strong></p> <p>for eg . <code>select custid from employee where (custid,name) in ((1,"ford"),(3,"eli"))</code></p> <p>This is normal query and it works, but here i have list of custid and name , so i want to pass list using IN Query.</p> <p>The query is </p> <pre><code>String sql="select employee.custid from Employee employee where (employee.id.custid,employee.id.name) IN ( (:listofcustid , :listofname ))"; </code></pre> <p>I am setting parameter as</p> <pre><code> Query query = em.createQuery(sql); query.setParameter("listofcustid", custidlist); query.setParameter("listofname", namelist); </code></pre> <p>But it is not working and giving exception </p> <pre><code> unexpected AST node: {vector} [ select employee.custid from com.dao.Employee employee where (employee.id.custid,employee.id.name) IN ((:custIdList0_, :custIdList1_, :custIdList2_),(:nameList0_, :nameList1_, :nameList2_))] </code></pre> <p>But for single List it is working fine</p> <pre><code> String sql="select employee.custid from Employee employee where employee.id.custid IN ( :listofcustid )"; query.setParameter("listofcustid",listofcustid); </code></pre> <p>and when i try to remove the inner braces </p> <pre><code>( :listofcustid , :listofname ) </code></pre> <p>it is giving this output with whole exact query with parameters in (? , ? , ? , ? , ? , ?),</p> <p>that means it is not taking it as tuple , followed by exception and following line also</p> <p><code>" ORA-00920: invalid relational operator "</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload