Basically this error is occurring when the BSON is deserialized to Java Object. _id field is mapped to null. Rest all other fields are mapped properly.
You can create Pojo objects and insert into a MongoDB collection as documents and retrieve them - without problem. All this using the default driver created ObjectId.
You can post the code related with creating the object (new Student(), setting the properties, etc.,), how you are inserting and retrieving.
Please use @BsonId and ObjectId along with fieldName ‘id’ you will get the objectId
some thing like
@BsonId
private ObjectId id;
reason is by default Bson will be using ‘_’ as word saparator of database feilds like below
lets take an example
DB field user_id
Pojo class userId then it will map to it.
It is working for me , hope will help you as well.