title: Hibernate query error with collection defined as Set
body: <p>This error is thrown from one of my jersey-glassfish rest endpoint ( from domain logs ):</p>
  
  <blockquote>
    <p>Caused by: java.lang.IllegalArgumentException: Type specified for TypedQuery [com.tanukis.streetama.entity.Flow] is incompatible with query return type [interface java.util.Set]
        at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:458)
        at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createNamedQuery(EntityManagerWrapper.java:566)
        at com.tanukis.streetama.dao.FluxManager.getBlacklist(FluxManager.java:571)</p>
  </blockquote>
  
  <p>The query is defined in orm.xml :</p>
  
  <pre><code>SELECT DISTINCT s.blacklistedFlow FROM StreetamaUser s WHERE s.uid = :uid
  </code></pre>
  
  <p>Here is my StreetamaUser entity:</p>
  
  <pre><code>@ManyToMany(cascade= javax.persistence.CascadeType.ALL)
  @JoinTable(
      name="ws_user_blacklist",
      uniqueConstraints = @UniqueConstraint(columnNames = { "blacklisted_flow_id", "user_id" }),
      joinColumns = {
          @JoinColumn(name="user_id",referencedColumnName="uid")
      },
      inverseJoinColumns = {
          @JoinColumn(name="blacklisted_flow_id",referencedColumnName="id")
      }
  )
  @XmlTransient
  private Set&lt;Flow&gt; blacklistedFlow = new HashSet&lt;Flow&gt;();
  </code></pre>
  
  <p>And the query call:</p>
  
  <pre><code>List&lt;Flow&gt; result = em.createNamedQuery( "StreetamaUser.findBlacklist", Flow.class )
              .setParameter("iduser", uid )
              .setFirstResult(startitem)
              .setMaxResults(itemnbr)
              .getResultList();
  </code></pre>
  
  <p>I can't understand the Hibernate exception. getResultList return a list, so why it complains about the query return type ? </p>