title: How to update embedded document in mongo?
body: <p>I am having the following document in the mongo db.</p>
  
  <pre><code>  { "_id" : ObjectId("50656f33a4e82d3f98291eff"), 
       "description" : "gdfgdfgdfg",
       "menus" : [    
                 {    
                   "name" : "gdfgdfgdfg",     
                    "description" : "dfgdgd",     
                    "text" : "dfgdfg",    
                    "key" : "2",  
                    "onSelect" : "yyy",   
                    "_id" : ObjectId("50656f3ca4e82d3f98291f00") 
                }, 
                 {    
                   "name" : "rtytry",     
                    "description" : "gffhf",  
                    "text" : "dfgdfg",    
                    "key" : "2",  
                    "onSelect" : "yyy",   
                    "_id" : ObjectId("50656f3ca4e82d3f98281f00") 
                }],
        "select":"ffdfgd"
     }
  </code></pre>
  
  <p>I want to do automatic update of menus 
                    {<br>
                       "name" : "gdfgdfgdfg",<br>
                        "description" : "dfgdgd",<br>
                        "text" : "dfgdfg",<br>
                        "key" : "2",<br>
                        "onSelect" : "yyy",<br>
                        "_id" : ObjectId("50656f3ca4e82d3f98291f00") 
                    } </p>
  
  <p>I have tried using the following code:</p>
  
  <pre><code>         BasicDBObject query = new BasicDBObject("_id", new ObjectId("50656f33a4e82d3f98291eff"));
  
           BasicDBObject update = new BasicDBObject("_id", ObjectId("50656f3ca4e82d3f98291f00"));
  
           BasicDBObject updateCommand = new BasicDBObject("$set", new BasicDBObject("menus", update));
  
           collection.update(query, updateCommand);
  </code></pre>
  
  <p>The result i got is </p>
  
  <pre><code>  { "_id" : ObjectId("50656f33a4e82d3f98291eff"), 
   "description" : "gdfgdfgdfg",
   "menus" :    
             {    
               "name" : "gdfgdfgdfg",     
                "description" : "dfgdgd",     
                "text" : "dfgdfg",    
                "key" : "2",  
                "onSelect" : "yyy",   
                "_id" : ObjectId("50656f3ca4e82d3f98291f00") 
            },
    "select":"ffdfgd"
  </code></pre>
  
  <p>}</p>
  
  <p>but i want to update in the same embedded document.</p>
  
  <p>Any one guide me ....Thanks in advance</p>