-->
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.  [ 1 post ] 
Author Message
 Post subject: Criteria API suggestion (IN expression)
PostPosted: Fri Apr 30, 2004 4:22 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
what i want to do is something similar to:
q=s.createQuery("from Kitten k where k.parent in (:cats)");
q.setParameterList("cats", catsCollection);

catsCollection contains Cat entities (not IDs!)..
this works flawlessly and is great..
Now I'd like to do the same with the criteria API, but the InExpression class insists that I specify a property name..

I know its possible to do it like this:
Criteria c = s.createCriteria(Kitten.class).add(Expression.in("parent", catsCollection));

but thats not what I want, since im building the criteria dynamically (the resulting query is not always the same), which is the very point of using criteria, right!? I think it would be nice to have an InExpression ctor taking only the collection of entities to match or a special property name like "this" to specify that the collection of values is actually entities of the same kind that has to be matched... something like:

Criteria c = s.createCriteria(Kitten.class).createCriteria("parent").add(Expression.in("this", catsCollection));

or

Criteria c = s.createCriteria(Kitten.class).createCriteria("parent").add(Expression.in(catsCollection));

Can anybody guide me to what I need to change to make this work the right way? (maybe a new InExpression class of my own?) ... please dont suggest any hacks, since thats what I'm trying to avoid..

Im sure it's not hard to change if you know the exact point of attack, so I guess thats what im looking for....

thanks...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.