-->
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: using Restrictions with 'not in' clause in Criteria?
PostPosted: Thu Jul 05, 2007 2:07 pm 
Newbie

Joined: Thu Jan 04, 2007 1:36 pm
Posts: 16
How can I use the 'not in' command using the Restrictions or Expression in creating a Criteria instance?
For ex. the SQL may look like this:

Code:
select * from dummy d where d.id not in (select  dummy_id from another_table)


Appreciate any suggestions provided.
Thanks.


Top
 Profile  
 
 Post subject: found the solution
PostPosted: Thu Jul 05, 2007 6:07 pm 
Newbie

Joined: Thu Jan 04, 2007 1:36 pm
Posts: 16
Never mind.. I digged a little deeper and found a solution:

Just created a DetachedCriteria and used that in the actual criteria which need to use the "not in" clause in its query...

Code:
criteria.add(Property.forName("id").notIn(detachedCriteria));


Thanks,
Arun


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.