-->
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.  [ 2 posts ] 
Author Message
 Post subject: Criteria Restriction for multiple OR conditions?
PostPosted: Thu Jul 16, 2009 4:33 pm 
Regular
Regular

Joined: Tue Apr 10, 2007 10:02 am
Posts: 56
I have a Criteria based query where the code will require multiple 'or' type restrictions. Yet the 'Restriction.or()' function only allows two parameters. How would you construct a Criteria query that had 5 different restrictions that are to be joined by 'or'?


Top
 Profile  
 
 Post subject: Re: Criteria Restriction for multiple OR conditions?
PostPosted: Thu Jul 16, 2009 4:59 pm 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
davout_uk wrote:
I have a Criteria based query where the code will require multiple 'or' type restrictions. Yet the 'Restriction.or()' function only allows two parameters. How would you construct a Criteria query that had 5 different restrictions that are to be joined by 'or'?


You can use :
Code:
    Criteria crit = session.createCriteria(Survey.class);
    Criterion address = Restrictions.like("address", "Jln. Ketapang", MatchMode.ANYWHERE);
    Criterion firstName = Restrictions.eq("name", "Agus");
    Disjunction disjunction = Restrictions.disjunction();
    disjunction.add(address);
    disjunction.add(firstName);
    crit.add(disjunction);


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

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.