Hibernate and Unexpected end of Subtree exception

hibernate, hql, java

Solution

For primitives collections you should use HQL query like this:

from Item item join item.labels lbls where 'hello' in (lbls)

PS: 'join' is required because 'labels' is OneToMany or ManyToMany variant, parentheses are required because 'lbls' is a collection

Problem

I'm a newbie to Hibernate. I have an `Item` POJO which contains a `Set<String>` consisting of labels. The labels are contained on another Database table from the `Item` table, so I do a join to populate the pojo. I'm trying to run a simple example query from the book "Java Persistance with Hibernate" where I query `from Item item where 'hello' member of item.labels`. Only, for some reason I am getting a ``` `org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree[from /*qualified class path*/.Item item where 'hello' member of item.labels]` ``` What might be causing this issue? Here are my POJOs: ``` public class Item private int uuid; private Set<String>labels = new HashSet<String>(); @Id public int getUuid(){ return uuid; } @CollectionOfElements @JoinTable(name="labels", joinColumns=@JoinColumn(name="uuid")) @Column(name="label") public Set<String> getLabels(){ return labels; } } ```

Original source