title: In a JPA query, how do I pass in a list for use as a single-column table?
body: <p>I have a list of IDs, and I need a query to return only those that do not exist in the specified table. I know that, in SQL, you can do it like this:</p>
  
  <pre><code>select *
  from ( 
     values (4),(5),(6)
  ) as v(id)
  where not exists (select *
     from images i
     where i.id = v.id);
  </code></pre>
  
  <p>(From this answer: <a href="https://dba.stackexchange.com/a/141137/11088">Link</a>)</p>
  
  <p>But I'm attempting to use a JPA <code>@Query</code>, and pass in the list as a parameter, which it doesn't seem to like.</p>
  
  <pre><code>SELECT t.id
  FROM :ids AS t(id)
  WHERE NOT EXISTS
      ([Nested select clause])
  </code></pre>
  
  <p>With</p>
  
  <pre><code>List&lt;Long&gt; findIdsMissingFromTable(@Param("ids") List&lt;Long&gt; ids, [...]
  </code></pre>
  
  <p>I have also tried <code>(VALUES :ids)</code>, which it also doesn't like, and removing the <code>AS</code> with the same result. In all cases, I get <code>QuerySyntaxException: unexpected token: ( near line 1, column 18 [...]</code> which seems to be the colon in the first case, or the open parenthesis in the second.</p>
  
  <p>What should I be doing instead?</p>