ObjectId created in java code not inserted to document

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Works as Designed
    • Priority: Minor - P4
    • None
    • Affects Version/s: 4.0.0
    • Component/s: Codecs, POJO
    • None
    • Environment:
      Windows 7 64 Bit, mongodb-driver 3.8.1
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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

       

       

            Assignee:
            Unassigned
            Reporter:
            Ahmad Thahir
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: