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: HQL, query collection, with collection
PostPosted: Wed Jan 30, 2008 9:38 am 
Newbie

Joined: Wed Sep 19, 2007 2:59 am
Posts: 14
Hi!
Im trying to write a search-function and i have the following problem, dont know how to best solv it in hql.

I have the objects Education and Category

Education
Id :GUID
Name :String
Categories: IList<Category>

Category
Id :GUID
Name:String

Calling my search function i pass a List<Category> in-parameter, and i want to get all the Education objects matching at least all the Categories in the List<Category> in-parameter.

Whats the best way to solve it in HQL?

In SQL i could use Intersect in a where subquery. I cant use in here because i want it to match all the items in the inparam, not one of them alone.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 31, 2008 5:45 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
My guess :

Pass two parameters, :cats (categories list) and :n ( :cats.Count )
Code:
select edu from Education edu where (select count(c) from edu.Categories c where c in (:cats) ) = :n

_________________
michal


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.