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.  [ 3 posts ] 
Author Message
 Post subject: About Criteria query??for three or more 'or' ??
PostPosted: Wed May 28, 2008 6:30 am 
Newbie

Joined: Fri May 09, 2008 11:55 pm
Posts: 2
I've a sql sentence:
select * from student where name='a' or name='b' or name ='c' or name ='d' or.......

I want to use Criteria query to implement it !
How Can I do this?
I almost wasted my whole day for that problem!!!!!for help in hurry!!!

THanks ,THX!!!!!!!!!!!!!!!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 28, 2008 7:24 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
If you query on different properties, you can do

Code:
criteria.Add(Expression.Disjunction()
    .Add(Expression.Eq("A", a))
    .Add(Expression.Eq("B", b))


or if it's all about one property:

Code:
criteria.Add(Expression.In("Name", stringArrayOfNames));

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 28, 2008 10:45 am 
Newbie

Joined: Fri May 09, 2008 11:55 pm
Posts: 2
wolli wrote:
If you query on different properties, you can do

Code:
criteria.Add(Expression.Disjunction()
    .Add(Expression.Eq("A", a))
    .Add(Expression.Eq("B", b))


or if it's all about one property:

Code:
criteria.Add(Expression.In("Name", stringArrayOfNames));

thX a lot ! i know the Disjunction()! but i do not know it has add() function!
i will carefull for this !
thX again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.