title: JPQL collection parameter - mismatch the expected type
body: <p>A bit of context: I have a Spring app with Hibernate. </p>
  
  <p>I want to get all Location entities filtered by ID so I pass a set of IDs as parameter to the query. The problem is that on the <code>query.setParameter("ids", locationIds);</code> row I get the following error:</p>
  
  <pre><code>:Parameter value element [728331] did not match expected type [java.lang.Long (n/a)]
  </code></pre>
  
  <p>I am confused since the set I am giving is set of Long values. So I assume no explicit casting should be done when passing it as parameter, right? Does anyone has suggestion what is causing the error?</p>
  
  <p>I checked other similar questions but I didn't find one that solve my issue.</p>
  
  <pre><code>@Repository
  @Transactional(propagation = Propagation.MANDATORY)
  public class LocationDao {
  
      @PersistenceContext
      private EntityManager em;
  
      public List&lt;Location&gt; getLocationsByIds(Set&lt;Long&gt; locationIds) {
          if (locationIds == null || locationIds.isEmpty()) {
              return null;
          }
          final TypedQuery&lt;Location&gt; query =
                  em.createQuery("FROM Location l WHERE l.id IN :ids", Location.class);
          query.setParameter("ids", locationIds);
          return query.getResultList();
      }
  }
  
  @Entity
  @Table(name = "location")
  public class Location {
  
      @Id
      private Long id;
  
      // other fields
  }
  </code></pre>
  
  <p>EDIT: Hibernate entity manager version: 4.3.8.Final</p>