title: Doing an "IN" query with Hibernate
body: <p>I have a list of IDs in a String, and want to use Hibernate to get the rows with these IDs. <code>TrackedItem</code> is a Hibernate/JPA entity (sorry if I'm getting the naming mixed up here).</p>
  
  <p>My code is:</p>
  
  <pre><code>String idsText = "380, 382, 386";
  ArrayList&lt;Long&gt; ids = new ArrayList&lt;Long&gt;();
  
  for (String i : idsText.split(","))
  {
      ids.add(Long.getLong(i));
  }
  
  List&lt;TrackedItem&gt; items = TrackedItem.find("id IN (?)", ids).fetch();
  </code></pre>
  
  <p>But that fails:
  <code>JPAQueryException occured : Error while executing query from models.TrackedItem where id IN (?): java.util.ArrayList cannot be cast to java.lang.Long</code></p>
  
  <p>How can I make the <code>IN</code> part work? Thanks.</p>