title: Repository query with a List parameter in Spring Data MongoDB
body: <p>I have the following POJO.</p>
  
  <pre><code>@Document(collection = "questions")
  public class Question {
  
      @Id
      private String id;
  
      public List&lt;String&gt; getTags() {
          return tags;
      }
  
      public void setTags(List&lt;String&gt; tags) {
          this.tags = tags;
      }
  }
  </code></pre>
  
  <p>I am trying to implement a <code>MongoRepository</code> query which finds all <code>Question</code>s that contain a list of tags. I have tried the following: </p>
  
  <pre><code>@Repository
  public interface QuestionRepository extends MongoRepository&lt;Question, String&gt; {
      List&lt;Question&gt; findByTags(List&lt;String&gt; tags);
  }
  </code></pre>
  
  <p>but this is only working when the <code>List</code> of tags that I'm passing to the method fully matches the list of tags assigned to the question in Mongo. E.g. if I have a question in Mongo with a list of tags <code>[ "t1", "t2", "t3" ]</code> it is not returned by <code>findByTags(List)</code> when I pass <code>[ "t1", "t2" ]</code> to the method.</p>
  
  <p>I have tried the following as well:</p>
  
  <pre><code>@Repository
  public interface QuestionRepository extends MongoRepository&lt;Question, String&gt; {
      @Query("{ tags: { $all: ?0 } }")
      List&lt;Question&gt; findByTags(List&lt;String&gt; tags);
  }
  </code></pre>
  
  <p>but then my <code>war</code> could not be deployed to my servlet container at all. (I get the following error in that case:</p>
  
  <pre><code>The web application [backend] appears to have started a thread named [cluster-1-db:27017] but has failed to stop it. This is very likely to create a memory leak.
  </code></pre>
  
  <p>Would you please advise on how to implement that custom query?</p>