-->
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 use Not In Function in Hibernate using Expression
PostPosted: Tue Jan 30, 2007 4:25 am 
Newbie

Joined: Tue Jan 30, 2007 4:18 am
Posts: 1
Hi Hibernate Experts,

Since 6 months I started using Hibernate in my application.
Currently I got a requirement to use "Not In" function in Hibernate.

Example Query:

SELECT * FROM V_NEWS_SUBJECT WHERE ID NOT IN (118,117,114,113,112,111,108,104,103,102,94,93,92,89,88,87)

I have observed that Hibernate has only IN function.

How to convert the above Query in Hibernate using "Expression"?

Can any one of you advise me how to implement this in Hibernate?

Immediate response would be appreciated.

Please do the needful.

Regards,

Rajasekhar Dara.

_________________
Rajasekhar Dara


Top
 Profile  
 
 Post subject: Re: How to use Not In Function in Hibernate using Expression
PostPosted: Tue Jan 30, 2007 4:42 am 
Newbie

Joined: Tue Dec 12, 2006 3:19 am
Posts: 17
Location: Spain
rsdara6 wrote:
Hi Hibernate Experts,
Example Query:
SELECT * FROM V_NEWS_SUBJECT WHERE ID NOT IN (118,117,114,113,112,111,108,104,103,102,94,93,92,89,88,87)


Hello
You could use Criteria Queries:
http://www.hibernate.org/hib_docs/v3/re ... g-criteria

The idea is to add a restrictions like the below one:

Code:
Criteria criterio = session.createCriteria(XXX.class);
Vector<Integer> foo =new Vector<Integer>();
foo.add(118);
foo.add(117);
[...]
foo.add(87);

criterio.add(
   Restrictions.not(
      Restrictions.in("V_NEWS_SUBJECT", foo)
   )
);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 9:28 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi i92absaj,

Hibernate 3.1 support to use not in

Ex

from AbcVO as abcVO where abcVO.xyz not in('243243')

_________________
Dharmendra Pandey


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.