select a from Article a where :numberOfTags =
(select count(distinct tag.id) from Article a2
inner join a2.tags tag
where tag in :tags
and a = a2)
This basically counts the tags of the articles that are tags in the accepted set of tags, and if the number of such tags is eaqual to the size of the accepted set of tags (meaning that all tags in the set are tags of the article), returns the article.