Hi,
I have read the forums and can see that I can perform a disjunction query i.e. select * from case where a=1 OR b=2 OR c=3 with multiple Criterion. The problem im struggling with is performing multiple OR queries with several Criteria...
I have a class with several lists of objects therefore I have several criteria to perform my restrictions e.g.
Criteria crit = session.createCriteria(Case.class);
Criteria custCrit = crit.createCriteria("customers");
Criteria issueCrit = crit.createCriteria("issues");
i then perform restrictions on serveral criteria i.e. on the issueCrit criteria i do..
Criterion statusRaised = eq("issue", "blah");
issueCrit.add(statusRaised);
This works and generates my SQL with AND restrictions between JOINS (ive simplified the sql greatky so hopefully the SQL is correct ;-)....
SELECT * FROM case
INNER JOIN customers
ON customer.id = case.id AND
INNER JOIN issues
ON issue.id = case.id WHERE issue=blah
However what I want is...
SELECT * FROM case
INNER JOIN customers
ON customer.id = case.id OR
INNER JOIN issues
ON issue.id = case.id WHERE issue=blah
looking at the API Restrictions.disjunction() allows me to add Criterion's but not Criteria objects. Am I misunderstanding something or have I structured my criteria incorrectly? How do is say OR with my Criteria's?
Many thanks, Andy
|