title: Passing empty list as parameter to JPA query throws error
body: <p>If I pass an empty list into a JPA query, I get an error.</p>
  <p>For example:</p>
  <pre><code>List&lt;Municipality&gt; municipalities = myDao.findAll();  // returns empty list
  em.createQuery(&quot;SELECT p FROM Profile p JOIN p.municipality m WHERE m IN (:municipalities)&quot;)
      .setParameter(&quot;municipalities&quot;, municipalities)
      .getResultList();
  </code></pre>
  <p>Because the list is empty, Hibernate generates this in SQL as &quot;IN ()&quot;, which gives me error with Hypersonic database.</p>
  <p>There is a ticket for this in <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-2045" rel="nofollow noreferrer">Hibernate issue tracking</a> but there are not many comments/activity there. I don't know about support in other ORM products or in JPA spec either.</p>
  <p>I don't like the idea of having to manually check for null objects and empty lists every time. Is there some commonly known approach/extension to this? How do you handle these situations?</p>