title: JPA 2 and Hibernate 3.5.1 MEMBER OF query doesnt work
body: <p>I'm trying the following JPQL and it fails misserably:</p>
  
  <pre><code>Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' MEMBER OF u.roles");
  List users = query.query.getResultList();
  </code></pre>
  
  <p>I get the following exception: </p>
  
  <pre><code>ERROR [main] PARSER.error(454) | &lt;AST&gt;:0:0: unexpected end of subtree
  java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT u FROM com.online.data.User u WHERE 'admin' MEMBER OF u.roles] ERROR [main] PARSER.error(454) | &lt;AST&gt;:0:0: expecting "from", found '&lt;ASTNULL&gt;'
  ...
  ...
  Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT u FROM com.online.data.User u WHERE 'admin' MEMBER OF u.roles]
  </code></pre>
  
  <p>I have Spring 3.0.1.RELEASE, Hibernate 3.5.1-Final and maven to glue dependencies.</p>
  
  <p>User class:</p>
  
  <pre><code>@Entity
  public class User {
    @Id
    @Column(name = "USER_ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(unique = true, nullable = false)
    private String username;
  
    private boolean enabled;
  
    @ElementCollection
    private Set&lt;String&gt; roles = new HashSet&lt;String&gt;();
  
  ...
  }
  </code></pre>
  
  <p>Spring configuration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
   xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="
         http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/tx/spring-context-3.0.xsd
         http://www.springframework.org/schema/tx 
         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
         http://www.springframework.org/schema/aop 
         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt;
  
   &lt;!-- Reading annotation driven configuration --&gt;
   &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
   &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt;
   &lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;
  
   &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
    &lt;property name="driverClassName" value="${jdbc.driverClassName}" /&gt;
    &lt;property name="url" value="${jdbc.url}" /&gt;
    &lt;property name="username" value="${jdbc.username}" /&gt;
    &lt;property name="password" value="${jdbc.password}" /&gt;
    &lt;property name="maxActive" value="100" /&gt;
    &lt;property name="maxWait" value="1000" /&gt;
    &lt;property name="poolPreparedStatements" value="true" /&gt;
    &lt;property name="defaultAutoCommit" value="true" /&gt;
   &lt;/bean&gt;
  
   &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
    &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
   &lt;/bean&gt;
  
   &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
    &lt;property name="jpaVendorAdapter"&gt;
     &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
      &lt;property name="showSql" value="true" /&gt;
      &lt;property name="databasePlatform" value="${hibernate.dialect}" /&gt;
     &lt;/bean&gt;
    &lt;/property&gt;
    &lt;property name="loadTimeWeaver"&gt;
     &lt;bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /&gt;
    &lt;/property&gt;
    &lt;property name="jpaProperties"&gt;
     &lt;props&gt;
      &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
      &lt;prop key="hibernate.current_session_context_class"&gt;thread&lt;/prop&gt;
      &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/prop&gt;
      &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
      &lt;prop key="hibernate.format_sql"&gt;false&lt;/prop&gt;
      &lt;prop key="hibernate.show_comments"&gt;true&lt;/prop&gt;
     &lt;/props&gt;
    &lt;/property&gt;
    &lt;property name="persistenceUnitName" value="punit" /&gt;
   &lt;/bean&gt;
  
   &lt;bean id="JpaTemplate" class="org.springframework.orm.jpa.JpaTemplate"&gt;
    &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
   &lt;/bean&gt;
  
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence"&gt;
  
   &lt;persistence-unit name="punit" transaction-type="RESOURCE_LOCAL" /&gt;
  
  &lt;/persistence&gt;
  </code></pre>
  
  <p>pom.xml maven dependencies.</p>
  
  <pre><code>  &lt;dependency&gt;
     &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
     &lt;artifactId&gt;hibernate&lt;/artifactId&gt;
     &lt;version&gt;${hibernate.version}&lt;/version&gt;
     &lt;type&gt;pom&lt;/type&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
     &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
     &lt;version&gt;${hibernate.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
     &lt;artifactId&gt;hibernate-annotations&lt;/artifactId&gt;
     &lt;version&gt;${hibernate.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
     &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
     &lt;version&gt;${hibernate.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
     &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
     &lt;version&gt;1.2.2&lt;/version&gt;
     &lt;type&gt;jar&lt;/type&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
     &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
     &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
     &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
     &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
     &lt;artifactId&gt;spring-security-taglibs&lt;/artifactId&gt;
     &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
     &lt;artifactId&gt;spring-security-acl&lt;/artifactId&gt;
     &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;javax.annotation&lt;/groupId&gt;
     &lt;artifactId&gt;jsr250-api&lt;/artifactId&gt;
     &lt;version&gt;1.0&lt;/version&gt;
    &lt;/dependency&gt;
   &lt;properties&gt;
    &lt;!-- Application settings --&gt;
    &lt;spring.version&gt;3.0.1.RELEASE&lt;/spring.version&gt;
    &lt;hibernate.version&gt;3.5.1-Final&lt;/hibernate.version&gt;
  </code></pre>
  
  <p>Im running a unit test to check the configuration and I am able to run other JPQL queries the only ones that I am unable to run are the IS EMPTY, MEMBER OF conditions.</p>
  
  <p>The complete unit test is as follows:</p>
  
  <p>TestIntegration</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations =  { "/spring/dataLayer.xml"})
  @Transactional
  @TransactionConfiguration
  public class TestUserDaoImplIntegration {
    @PersistenceContext
    private EntityManager em;
  
    @Test
    public void shouldTest() throws Exception {
      try {
  //WORKS
  Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' in elements(u.roles)"); 
  List users = query.query.getResultList();
      } catch (Exception e) {
        e.printStackTrace();
        throw e;
      }
      try {
  //DOES NOT WORK
  Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' MEMBER OF u.roles"); 
  List users = query.query.getResultList();
      } catch (Exception e) {
        e.printStackTrace();
        throw e;
      }
    }
  }
  </code></pre>