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!
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))
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)