I am a little confused about how to do something in HQL.
So let's say I have a Foo class that I save in sleep mode. It contains a set of enumeration values, for example:
public class Foo { @CollectionOfElements private Set<Bar> barSet = new HashSet<Bar>();
and
public enum Bar { A, B }
Is there an HQL instruction that I can use to retrieve only Foo instances for which barSet contains Bar.B?
List foos = session.createQuery("from Foo as foo " + "where foo.barSet.contains.Bar.B").list();
Or am I stuck all instances of Foo and filters them at the DAO level?
List foos = session.createQuery("from Foo as foo").list(); List results = new ArrayList(); for(Foo f : foos) { if(f.barSet.contains(Bar.B)) results.add(f); }
Thanks!
java collections hibernate hql
Seth
source share