title: hibernate unexpected end of subtree when dealing with collection of basics
body: <p>i have the following entity:
  <code><pre>
  @Entity
  public class AnalysisPolicy extends PersistentEntity{
      private Set nodeIds;</p>
  
  <pre><code>@ElementCollection(fetch = FetchType.EAGER)
  @CollectionTable(
          name="analysis_policy_nodes",
          joinColumns=@JoinColumn(name="analysis_policy_id")
  )
  @Column(name="node_id")
  public Set&lt;Long&gt; getNodeIds() {
      return nodeIds;
  }
  </code></pre>
  
  <p>}
  </pre></code></p>
  
  <p>and im trying the following JPQL query:
  <code><pre>
  select p from AnalysisPolicy p where p.nodeIds is not empty
  </pre></code></p>
  
  <p>the result is something like:
  <code><pre>
  10:11:16,665 DEBUG [org.hibernate.hql.ast.AST] --- SQL AST ---
   -[SELECT] QueryNode: 'SELECT'  querySpaces (AnalysisPolicy,analysis_policy_nodes)
      +-[SELECT_CLAUSE] SelectClause: '{select clause}'
      |  -[ALIAS_REF] IdentNode: 'analysispo0_.f_id as f1_8_' {alias=p, className=com.emc.dpa.datamodel.analysis.AnalysisPolicy, tableAlias=analysispo0_}
      +-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[p], fromElementByTableAlias=[analysispo0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
      |  -[FROM_FRAGMENT] FromElement: 'AnalysisPolicy analysispo0_' FromElement{explicit,collection join,not a fetch join,fetch non-lazy properties,classAlias=p,role=null,tableName=AnalysisPolicy,tableAlias=analysispo0_,origin=null,columns={,className=com.emc.dpa.datamodel.analysis.AnalysisPolicy}}
      -[WHERE] SqlNode: 'where'
         -[EXISTS] UnaryLogicOperatorNode: 'exists'
            -[SELECT] QueryNode: 'SELECT'  querySpaces (AnalysisPolicy,analysis_policy_nodes)
               +-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
               +-[FROM] FromClause: 'from' FromClause{level=2, fromElementCounter=0, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[nodeids1_], fromElementsByPath=[], collectionJoinFromElementsByPath=[p.nodeIds], impliedElements=[]}
               |  -[FROM_FRAGMENT] ImpliedFromElement: 'analysis_policy_nodes nodeids1_' ImpliedFromElement{implied,collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=com.emc.dpa.datamodel.analysis.AnalysisPolicy.nodeIds,tableName={none},tableAlias=nodeids1_,origin=AnalysisPolicy analysispo0_,columns={,className=null}}
               -[WHERE] SqlNode: 'WHERE'
                  -[THETA_JOINS] SqlNode: '{theta joins}'
                     -[SQL_TOKEN] SqlFragment: 'analysispo0_.f_id=nodeids1_.analysis_policy_id'</p>
  
  <p>10:11:16,681 DEBUG [org.hibernate.hql.ast.ErrorCounter] throwQueryException() : no errors
  10:11:16,712 ERROR [org.hibernate.hql.PARSER] :0:0: unexpected end of subtree
  </pre></code></p>
  
  <p>followed by a long stack trace. i've found a similar stackoverflow issue <a href="https://stackoverflow.com/questions/2066361/hibernate-and-unexpected-end-of-subtree-exception">here</a> where the problem was that the syntax is different for collections of basic entities, so what im currently thinking is that my "is not empty" part should be replaces with something else.
  also, I couldn't get "is not null" to work. "size(nodeIds)>1" works but the generated SQL has an inner select which would be really bad in terms of performance.</p>
  
  <p>what are my ways around this? (assuming I don't want to "upgrade" the collection to a collection of entities).</p>