title: How to delete document by _id in MongoDB 3.3 using Java
body: <p>I'm having a bit of an issue figuring out how to delete a document by _id in MongoDB. I can delete by other attributes no problem but I seem to be missing the correct syntax for deleting by _id.</p>
  
  <p>My document has the following format :</p>
  
  <pre><code>{ "_id" : { "$oid" : "57a49c6c33b10927ff09623e" }, "name" : "Brad" }
  </code></pre>
  
  <p>And here is the Java code I am using :</p>
  
  <pre><code>// Boiler plate
  MongoClient client = new MongoClient( "localhost" , 27017 );
  MongoDatabase db = client.getDatabase("my-database");
  MongoCollection&lt;Document&gt; collection = db.getCollection("my-collection")
  
  // This works
  collection.deleteOne(new Document("name", "Brad"));
  
  // This does not work
  collection.deleteOne(new Document("_id", "57a49c6c33b10927ff09623e"));
  </code></pre>
  
  <p>Anyone have any idea where I am going wrong?</p>