When inserting a new POJO into a collection, the _id is properly correctly generated in the document representation but the POJO ID property is not populated:
MongoCollection<Document> collection; Document document = new Document(); collection.insertOne(document); // document.get("_id") = 5a1786851ce328045c0c5276 <----- _id populated as expected after insert public class Widget { private ObjectId id; public String getId() { return id; } public void setId(ObjectId id) { this.id = id; } } MongoCollection<Widget> collection; // (PojoCodecProvider configured for automatic) Widget widget = new Widget(); collection.insertOne(widget); // widget.getId() == null <----- id value still null; // The ID property is properly populated when using find Widget widget = collection.find(...); widget.getId() == 5a1786851ce328045c0c5276 <--- id value set as expected