title: How to update an array item in MongoDB with two "where" condition using java driver
body: <p>I have a collection called "XX" and in this collection I have several documents. I am matching on the field "userEmail".</p>
  
  <p>This is the structure of the document:</p>
  
  <pre class="lang-js prettyprint-override"><code>{ "_id" : { "$oid" : "5331e4e313163623bb649249"} ,
     "userEmail" : "user3@this.com"} 
     "reservations" : [ { 
          "idRest" : "23" , 
          "userPhone" : "88888888" , 
          "date" : "03-13-2015" , 
          "hour" : "14:30" 
     },
     { 
          "idRest" : "24" , 
          "userPhone" : "88888888" , 
          "date" : "03-13-2015" , 
          "hour" : "17:30" 
     },
     { 
          "idRest" : "22" , 
          "userPhone" : "88888888" , 
          "date" : "03-13-2015" , 
          "hour" : "16:30" 
    }]
  </code></pre>
  
  <p>}</p>
  
  <p>And now I need find the document where "userEmail" = "some@some.com" and update the fields of the array where "idRest" = 24. in this case:</p>
  
  <pre class="lang-js prettyprint-override"><code>{ 
      "idRest" : "24" , 
      "userPhone" : "88888888" , 
      "date" : "03-13-2015" , 
      "hour" : "17:30" 
  },
  </code></pre>
  
  <p>Can you help me please to build the query using JAVA driver :) thanks in advance!!</p>
  
  <hr>
  
  <p><strong>EDIT</strong>: this is my code, but instead of update the fields add a new sub document</p>
  
  <p>`</p>
  
  <pre><code>DBCollection collReservationByUser = db.getCollection(usersReservationCollection);
  
  DBObject queryx = new BasicDBObject("userEmail", rest.getEmailUser());
  
  BasicDBObject document1 = new BasicDBObject();
  
  document1.put("idRest", rest.getEmailUser());
  document1.put("userPhone", rest.getPhoneUser());
  document1.put("date", rest.getFecha());
  document1.put("hour", rest.getHora());;
  
  DBObject update1 = new BasicDBObject();
  update1.put("$push", new BasicDBObject("reservations", document1));
  collReservationByUser.update(queryx, update1, true, true);`
  </code></pre>