Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2955

ObjectId created in java code not inserted to document

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

      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 Unassigned
            Reporter:
            ataherster@yahoo.co.id Ahmad Thahir
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: