-->
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.  [ 4 posts ] 
Author Message
 Post subject: negation of an expression
PostPosted: Tue Jan 27, 2004 11:20 am 
Newbie

Joined: Tue Jan 27, 2004 11:02 am
Posts: 4
Hello,

In my application a have a Project class with a collection of Persons.
I want to present a list of Persons in the database which are not in this collection, so if I have 4 Persons in the database and I have a project which has person1 in it's collection, I want to show person2 till person4.
Therefore, I've made a collection of Person ID's which belong to my Project, and tried to create a Criteria query as follows:

Collection persons =
session
.createCriteria(Person.class)
.add(Expression.not(Expression.in("ID", personIDs)))
.list();

But here the returned collection is empty, so this doesn't work.

I've also tried this query:

Collection persons =
session
.createCriteria(Person.class)
.add(Expression.in("ID", personIDs))
.list();

- the query I want to negate - and this works fine, here person1 is returned.

So my question is: how can I negate the above query?

Best regards,
Arjan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2004 11:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
MySQL? If yes, this is a mysql bug, next Hibernate version will include a workaround.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2004 11:26 am 
Newbie

Joined: Tue Jan 27, 2004 11:02 am
Posts: 4
MySql indeed! Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2004 11:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Take a look at this thread: http://forum.hibernate.org/viewtopic.php?t=926765&highlight=criteria for a user level workaround.


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