How to check is ALL elements of a collection exists in another collection in HQL

i have a Course entity that have a mapped collection of Skill entities. now i want to check thru HQL if all the elements of course.skills collection exists in another collection which i will be passing as a parameter in the query.

i can check if one element is already in the other collection using IN statement, but i can't seem to figure out how to check is ALL elements are present.

hope someone could help me out. thanks!

Answers


I would love to find a more elegant solution to this problem, but I solve it with such a query:

select course from Course course
where not exists (
    select skill.id from Skill skill
    where skill.id in :setOfSkillIdsToHave
    and skill.id not in (
        select courseSkill.id
        from Course course2
        inner join course2.skills courseSkill
        where course2.id = course.id))

or,

select course from Course course
where :numberOfSkillsToHave = (
    select count(skill.id)
    from Course course2
    inner join course2.skills courseSkill
    where courseSkill.id in :setOfSkillIdsToHave
    and course2.id = course.id)       

Need Your Help

Cell image view geting bigger when i scroll

ios objective-c uitableview uiimage

I'm new to Objective-C and i want to display images in a table view. The images are from an URL.

C#: Test if string is a guid without throwing exceptions?

c# string parsing guid

I want to try to convert a string to a Guid, but I don't want to rely on catching exceptions (

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.