0

So my question is fairly similar to the one in Finding all entries where a collection field contains any of the given items

Except that rather than:

List<Message> findDistinctByTagsIn(Set<Tag> tag);

returning all Messages with ANY of the given tags, I'd like to know the syntax for a query that will only return messages that contain ALL of the given tags.

1 Answers1

0

If you are looking for ALL, you can see how the sql ALL clause works on internet. You can then define it as a custom query in the @Query annotation, which will let you define your own sql such as below

@Query( "select t from Tags t where tag_ids =  all :ids" )
List<Message> findAllDistinctByTags(@Param("ids") Set<Tag> tag);
amdg
  • 2,211
  • 1
  • 14
  • 25