title: Why does this enum parameter work for a single field and not for a collection?
body: <p>Consider the following JPA Entity (implementation is Hibernate 4.3.0):</p>
  
  <pre><code>@Entity
  public class MyEntity {
  
      @Id
      protected long myEntityId;
  
      @Enumerated(EnumType.STRING)
      public Condition myCondition = Condition.BAD;
  
      @Enumerated(EnumType.STRING)
      @ElementCollection
      public Set&lt;Condition&gt; conditions = new HashSet&lt;Condition&gt;();
  
      public enum Condition {
          GOOD, FAIR, BAD, SOL
      }
  }
  </code></pre>
  
  <p>When I run the following query with an enum parameter, I get 0 results (no error):</p>
  
  <pre><code>//Produces no results
  String queryString = "FROM MyEntity me WHERE :condition MEMBER OF me.conditions";
  List&lt;MyEntity&gt; things = JPA.em().createQuery(queryString, MyEntity.class).setParameter("condition", Condition.BAD).getResultList();
  </code></pre>
  
  <p>This query produces the following SQL:</p>
  
  <pre><code>select myentity0_.myentityid as myentity1_38_, myentity0_.mycondition as mycondit2_38_ 
  from MyEntity myentity0_ 
  where ? in (
      select conditions1_.conditions 
      from MyEntity_conditions conditions1_ 
      where myentity0_.myentityid=conditions1_.MyEntity_myEntityId)
  </code></pre>
  
  <p>If I use a string literal instead, I get results.  I also get results if I use the same parameter strategy for non-collection fields:</p>
  
  <pre><code>// Produces results
  queryString = "FROM MyEntity me WHERE 'BAD' MEMBER OF me.conditions";
  things = JPA.em().createQuery(queryString, MyEntity.class).getResultList();
  
  // Also produces results
  queryString = "FROM MyEntity me WHERE me.myCondition = :condition";
  things = JPA.em().createQuery(queryString, MyEntity.class).setParameter("condition", Condition.BAD).getResultList();
  
  //So does this
  String queryString = "from MyEntity me join me.conditions c where c = :condition";
  List&lt;MyEntity&gt; things = JPA.em().createQuery(queryString, MyEntity.class).setParameter("condition", Condition.BAD).getResultList();
  </code></pre>
  
  <p>These queries produce the following SQL:</p>
  
  <pre><code>select myentity0_.myentityid as myentity1_38_, myentity0_.mycondition as mycondit2_38_ 
  from MyEntity myentity0_ 
  where 'BAD' in (
      select conditions1_.conditions 
      from MyEntity_conditions conditions1_ 
      where myentity0_.myentityid=conditions1_.MyEntity_myEntityId)
  
  select myentity0_.myentityid as myentity1_38_, myentity0_.mycondition as mycondit2_38_ 
  from MyEntity myentity0_ 
  where myentity0_.mycondition=?
  
  select myentity0_.myentityid as myentity1_38_, myentity0_.mycondition as mycondit2_38_ 
  from MyEntity myentity0_ 
      inner join MyEntity_conditions conditions1_ on myentity0_.myentityid=conditions1_.MyEntity_myEntityId 
  where conditions1_.conditions=?
  </code></pre>
  
  <p>Am I wrong in my assumption that Hibernate should take care of <code>EnumType.STRING</code> and <code>EnumType.ORDINAL</code> when you use parameters?  At the least, it's inconsistent.  Filling in parameters works when querying enum fields but not enum collections.  What am I missing?</p>