Halo,
I tried inserting data through POJO, I made my own ObjectId in the POJO object with the code as below :
ObjectId oid = ObjectId.get();
res.set_id = oid;
resCollection.insertOne(res);
the problem arises when I check the results of ObjectId, it is not the same as the code created with the data entered in the document, after I do the experiment, I see that the error is in the getter naming for ObjectId, here are the results:
getId -> result : ObjectId created is same as the one entered in the document
getid -> resutl : ObjectId in document not the same as the code created
get_Id -> resutl : ObjectId in document }}{{ not the same as the code created
get_id -> resutl : ObjectId in document }}{{not the same as the code created
from the three getter naming that failed to insert ObjectId to document, I don't see any additional fields in the collection (id, _Id), I am not sure this is a bug or not, but I think that this explanation is very necessary
I also did some tests, my conclusion, the three getter naming that failed to enter the ObjectId to document, actually read by the POJO codec, but ignored & ObjectId was finally created by mongodb server
Thanks
Thahir