title: Spring data mongodb Criteria for nested array elemmatch
body: <p>I am trying to query a mongo db document That's contain nested array.</p>
  
  <p>Here is my beans : </p>
  
  <pre><code>public class Invitation {
      @JsonIgnore
      private UUID id;
  
      @DBRef
      private Personne personne;
  
      private List&lt;Boolean&gt; disponibilites;
  
      private InvitationStatus status;
  
      @DBRef
      private Groupe groupe;
  </code></pre>
  
  <p>And Groupe :
  @Document(collection = "groupe")</p>
  
  <pre><code>public class Groupe {
      @Id
      private String id;
      private String nom;
      private List&lt;Personne&gt; membres;
      @DBRef
      private Personne owner;
  
      public Groupe(){
  
      }
  </code></pre>
  
  <p>And here is the document im trying to query :</p>
  
  <pre><code>@Document(collection = "evenement")
  public class Sondage {
  
      @Id
      private String id;
      private String nom;
     // @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
      private Date dateCreation;
      private Date dateExpiration;
      private List&lt;Invitation&gt; invitations;
  </code></pre>
  
  <p>So here is my query :</p>
  
  <pre><code>Criteria finished = Criteria.where(SONDAGE_STATUS).is(SondageStatus.FINISHED);
  Criteria isExpired = Criteria.where(DATE_EXPIRATION).gt(new Date());
  // liste des personnes invitées dans un groupe
  Criteria member = Criteria.where("invitations.groupe.membres").elemMatch(Criteria.where("id").is(personId));
  Query bquery = new Query(new Criteria().andOperator(isExpired,finished,member));
  bquery.with(sort);
  bquery.fields().position("invitations.groupe.membres", 1);
  List&lt;Sondage&gt; membersInvitationList = mongoTemplate.find(bquery, Sondage.class);
  </code></pre>
  
  <p>When I launch my service I get this error : org.springframework.data.mapping.model.MappingException: Invalid path reference invitations.groupe.membres.id! Associations can only be pointed to directly or via their id property!</p>
  
  <p>Can anyone help me please ?</p>