-->
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: How to do a not equals search using Example/Criteria APIs
PostPosted: Wed Mar 30, 2011 6:02 pm 
Newbie

Joined: Wed Mar 16, 2011 10:54 am
Posts: 4
Hi,
Gradually getting my head around the Criteria API and how easy it can make database lookups. However , I cannot find a way to do an sql notEquals equivalent search. ie Setup an Example object with property name = "mick" and then pass this to the criteria API and have it return me a list of all instances who's name is NOT = "mick".

Is this possible?

Thanks


Top
 Profile  
 
 Post subject: Re: How to do a not equals search using Example/Criteria APIs
PostPosted: Thu Mar 31, 2011 2:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

there is
Code:
Restrictions.eq( "name", "mick" )

for equals and:
Code:
Restrictions.ne( "name", "mick" )

for not equals.

Is this what you are after?
Btw, this is really a questions for the Hibernate Users forum ;-)

--Hardy


Top
 Profile  
 
 Post subject: Re: How to do a not equals search using Example/Criteria APIs
PostPosted: Thu Mar 31, 2011 4:49 pm 
Newbie

Joined: Wed Mar 16, 2011 10:54 am
Posts: 4
Thanks for reply, that was it. I thought I had this one was in the users forum :( cheers


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.