-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Disjunction query with multiple criteria
PostPosted: Thu Jul 12, 2007 9:39 am 
Newbie

Joined: Thu Jul 12, 2007 9:11 am
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.