-->
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: nested or statements in hibernate criteria
PostPosted: Tue Jun 23, 2009 10:52 pm 
Newbie

Joined: Tue Jun 23, 2009 10:44 pm
Posts: 2
Anyone has come across the problem where you need to define multiple or statement in a hibernate criteria. Consider the following code segment:
Code:
Criteria crit = session.createCriteria(Project.class);
           Criteria jobs = crit.createCriteria("jobTypes");
jobs.add(Restrictions.or(Restrictions.eq("id", 1),
                 Restrictions.or(Restrictions.eq("id", 2),
                       Restrictions.or(Restrictions.eq("id", 3),
                             Restrictions.or(Restrictions.eq("id", 4),Restrictions.eq("id", 5))
           ))));


Now, how would one create such a nested OR cirterion using for/while loop if one has any number of different ids {1,2,3,4,5,6.....}?

Thanks,
Rizwan


Top
 Profile  
 
 Post subject: Re: nested or statements in hibernate criteria
PostPosted: Sun Jun 28, 2009 4:30 pm 
Newbie

Joined: Tue Jun 23, 2009 10:44 pm
Posts: 2
anyone came across this problem yet?
Any help would be appreciated.

Thanks,
Rizwan


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.