title: How to check if query params lists are empty into sql query
body: <p>I have some queries in sequence to find a series of lists with rows whose id is into a first list but if they are not present into second list.
  I'm using JPQL, Spring Boot and Postgres so one of my query is similar to:</p>
  <pre><code>@Query(&quot;from MyObject m where (size(:ids)&gt;0 and m.id in (:ids)) and (:size(:toExclude)&gt;0 and m not in (:toExclude)&quot;)
  List&lt;MyObject&gt; findAllAfterTwoChecks (List&lt;&gt;ids, List&lt;MyObject&gt;toExclude);
  </code></pre>
  <p>If one or both lists are empty, Hibernate returns nothing, because for it in(null) is false.
  How is it possibile to have all records if one or both lists are empty, in addition to these checks?</p>
  <p>I tried with coalesce() function but I had a problem with indexes.</p>
  <p>Thanks a lot.</p>