I am writing a JPQL query and i have the following scenario. I have a Question entity which contains a list of Tags. I would like to select all Questions that contains a given List of tags. How do i do this with JPA?
I would like to do something like SELECT x FROM Question x WHERE x.tags 'contains all' :tags
Try like this:
select distinct q from Question q join q.tags as t
where t.name in (:tags)
group by q.id, q.author, q.title, q.content,q.postedAt
having count(t.id) = :size