title: How to filter in mongo repository for array of objects
body: <p>Here i'm using MongoRepository and i need to query a list of objects that includes certain id in an array of objects inside. </p>
  
  <p>The document structure :</p>
  
  <pre><code>{
   "_id" : ObjectId("5ccc1c54a3d5eed9a6b8015a"),
   "email" : "sineth3@gmail.com",
   "name" : "edward3",
   "businessName" : "aroma3",
   "phone" : "07177222233",
   "address" : "no 100 NY",
   "bookletSignups" : [
      {
          "bookletId" : "sample-booklet",
          "contactName" : "john doe"
      },
      {
          "bookletId" : "sample-booklet1",
          "contactName" : "john doe1"
      }
   ],
    "eventSignups" : [
      {
          "eventId" : "sample-event",
          "contactName" : "john doe2"
      },
      {
          "eventId" : "sample-event 1",
          "contactName" : "john doe3"
      }
   ],
    "infoSignups" : [
      {
          "infoRequestId" : "sample-info ",
          "contactName" : "john doe4"
      },
      {
          "infoRequestId" : "sample-event 1",
          "contactName" : "john doe5"
      }
   ],
    "webinarSignups" : [
      {
          "webinarId" : "sample-webinar ",
          "contactName" : "john doe6"
      },
      {
          "webinarId" : "sample-webinar 1",
          "contactName" : "john doe7"
      }
   ],
   "updatedTime" : ISODate("2016-03-03T08:00:00Z")
  }
  </code></pre>
  
  <p>The Repository :</p>
  
  <pre><code>@Repository
  public interface UserRepository extends MongoRepository&lt;User,String&gt; {
  
     @org.springframework.data.mongodb.repository.Query(value = "{ 'bookletSignups': { $elemMatch: { 'bookletSignups.bookletId' : ?0 } }}")
     List&lt;User&gt; findByBookletId(String id);
  
  }
  </code></pre>
  
  <p>User model class:</p>
  
  <pre><code>@Id
  private String id;
  private String email;
  private String name;
  private String businessName;
  private String phone;
  private String address;
  @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
  private Date createdTime;
  @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
  private Date updatedTime;
  @Field("bookletSignups")
  @DBRef
  private List&lt;BookletSignUp&gt; bookletSignups;
  @Field("eventSignups")
  @DBRef
  private List&lt;EventSignUp&gt; eventSignups;
  @Field("infoSignups")
  @DBRef
  private List&lt;InfoSignUp&gt; infoSignups;
  @Field("webinarSignups")
  @DBRef
  private List&lt;WebinarSignUp&gt; webinarSignups;
  </code></pre>
  
  <p>So im trying to retrieve User objects that includes a bookletSignups object with the passing bookletId value. But the result is empty. What has gone wrong here?</p>