title: Update nested array list in mongodb java
body: <p>hello all i have a collection like this ` "_id" : ObjectId("55dabba974cd60712be24443"),</p>
  
  <pre><code>    "entityType" : "1",
      "entityCreatedDate" : "08/24/2015 12:07:20 PM",
      "nameIdentity" : [
              {
                      "givenNameOne" : "JOY",
                      "givenNameThree" : "BRAKEL",
                      "lastName" : "BRAKEL",
                      "createdDate" : "08/24/2015 12:07:20 PM",
                      "sourceId" : [
                              {
                                      "sourceId" : "55dabba974cd60712be24441"
                              }
                      ]
              },
  
      ],
  </code></pre>
  
  <p><code>
  Here name identity is a list as well as sourceId. I am trying to update sourceId list in nameIdentityList if it matches the names. My java code is :</code></p>
  
  <pre><code>Document sourceDocument=new Document("sourceId",sourceId);
  mongoDatabase.getCollection("entity").updateOne(new Document("entityId", entityId).append("nameIdentity.givenNameOne","JOY"),
                                  new Document("$push", new Document("nameIdentity.sourceId", sourceDocument)));
  </code></pre>
  
  <p>` But i am getting exception like java.lang.RuntimeException: com.mongodb.MongoWriteException: cannot use the part (nameIdentity of nameIdentity.sourceId) to traverse the element ({nameIdentity. </p>
  
  <p>If my condition is satisfied i am expecting like this: </p>
  
  <pre><code>`"_id" : ObjectId("55dabba974cd60712be24443"),
  
          "entityType" : "1",
          "entityCreatedDate" : "08/24/2015 12:07:20 PM",
          "nameIdentity" : [
                  {
                          "givenNameOne" : "JOY",
                          "givenNameThree" : "BRAKEL",
                          "lastName" : "BRAKEL",
                          "createdDate" : "08/24/2015 12:07:20 PM",
                          "sourceId" : [
                                  {
                                          "sourceId" : "55dabba974cd60712be24441"
                                  },
                                  {
                                          "sourceId" : "55dabba974cd60712be24435"
                                  }
                          ]
                  },
  
          ],`
  </code></pre>
  
  <p>. any suggestions where am i going wrong?
  I have multiple names in my nameIdentity, even if the matched document is second or third , sourceId is always being appened to first document. How do i update to specific matched document.</p>