title: Hibernate criteria query on different properties of different objects
body: <p>Suppose I have classes like:</p>
  
  <pre><code>class A {
   B getB();
   C getC();
  }
  
  class B {
   String getFoo();
  }
  
  class C {
   int getBar();
  }
  </code></pre>
  
  <p>and I want to filter criteria on A, two filters on different subclass properties, like:</p>
  
  <pre><code>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));
  </code></pre>
  
  <p>What I want to do is combine criteriaB and criteriaC using an "or" clause, something like:</p>
  
  <pre><code>//this does not work
  criteriaA.add(Restrictions.disjunction().add(criteriaB).add(criteriaC));
  </code></pre>
  
  <p>How can I accomplish this? I am stumbling a little over the API here.</p>