title: Update an array using MongoDB
body: <p>I have JSON like :</p>
  
  <blockquote>
    <p>{ "_id" : "1", "_class" : "com.model.Test",  "itemList" : [ 
    {       "itemID" : "1",   "itemName" : "Foo",
             "resources" : [ {       "resourceID" : "1",  "resourceName" : "Foo Test1",  }, {       "resourceID" : "2",  "resourceName" : "Foo
    Test2",  }  ] } ] }</p>
  </blockquote>
  
  <p>I need to be able to update the list of resources.
  I have done the following:</p>
  
  <pre><code>    BasicDBObject updateQuery = new BasicDBObject();
      updateQuery.put("id", "1");
  
      BasicDBObject updateCommand = new BasicDBObject();
  
      List&lt;Resource&gt; resources = populateResources();//Fetch a new list of Resources
      updateCommand.put("$push", new BasicDBObject("resources", resources));
  
  
      MongoOperations mongoOperations = mongoConfiguration.getMongoTemplate();
      DBCollection db = mongoOperations.getCollection("myCollection");
      db.save(updateCommand);
  </code></pre>
  
  <p>I get the follwoing error:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: fields stored in the db can't
    start with '$' (Bad Key: '$push')</p>
  </blockquote>
  
  <p>When I used : </p>
  
  <pre><code>db.update( updateQuery, updateCommand, true, true );
  </code></pre>
  
  <p>I got the following exception:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: can't serialize class
    com.model.Test</p>
  </blockquote>
  
  <p>I've tried :
  db.updateMulti(updateQuery, updateCommand);
  I didn't get neither any exceptions nor any updates takes place into the documents.</p>
  
  <p>So what am I missing here !!</p>