title: Mongodb update an object in multi nested array
body: <p>I have a document in mongodb with 2 level deep nested array of objects that I need to update, something like this.</p>
  
  <pre><code>{
    "id":12362,
    "onGoing":[
      {
        "id":14597,
        "offers":[
          {
            "id":56897,
            "status":"validated"
          },
          {
            "id":86127,
            "status":"validated"
          }
        ]
      },
      {
        "id":89451,
        "offers":[
          {
            "id":12235,
            "status":"validated"
          },
          {
            "id":56457,
            "status":"validated"
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>I would like to update all offers matching with their id.</p>
  
  <p>I have tried to update like</p>
  
  <pre><code>db.repairJobs.update({
    "onGoing.offers":{
      $elemMatch:{
        _id:{
          $in:[
            '56897', '56457'
          ]
        }
      }
    }
  },
  {
    $set:{
      "ongoing.offers.$.status":"ACCEPTED"
    }
  });  
  </code></pre>
  
  <p>But getting the error: cannot use the part (ongoing of ongoing.offers.0.status) to traverse the element ({ongoing: [ { _id: null, ...</p>
  
  <p>Are there any ways to update, the solution need to be compatible with spring Data.</p>