I'm a little confused about how to do something in HQL.
So let's say I have a class Foo that I'm persisting in hibernate. It contains a set of enum values, like so:
public class Foo
{
@CollectionOfElements
private Set<Bar> barSet = new HashSet<Bar>();
//getters and setters here ...
}
and
public enum Bar
{
A,
B
}
Is there an HQL statement I can use to fetch only Foo instances who'se barSet containst Bar.B?
List foos = session.createQuery("from Foo as foo " +
"where foo.barSet.contains.Bar.B").list();
Or am I stuck fetching all Foo instances and filtering them out 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!