Suppose I have classes like:
class A {
B getB();
C getC();
}
class B {
String getFoo();
}
class C {
int getBar();
}
and I want to filter criteria on A, two filters on different subclass properties, like:
Criteria criteriaA = session.createCriteria(A.class);
Criteria criteriaB = criteriaA.createCriteria("b").add(Restrictions.eq("foo", "Something"));
Criteria criteriaC = criteriaA.createCriteria("c").add(Restrictions.eq("bar", 0));
What I want to do is combine criteriaB and criteriaC using an "or" clause, something like:
//this does not work
criteriaA.add(Restrictions.disjunction().add(criteriaB).add(criteriaC));
How can I accomplish this? I am stumbling a little over the API here.