I have Question regarding saving java object in mongoDB and getting mongo Id back

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.6.0
    • Component/s: API, BSON, Codecs
    • None
    • Environment:
      i am using java 1.8 and mongo java Driver version 3.6
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hi Team , 

      I saving my java object to mongo DB using proper codec and able to save object in mongo

      i am using collection.insertOne(javaObject);

      i have @BsonId ObjectId id in my class . when i save object to database i don't see database generated id reflecting in  ObjectId id (i see this is as null , even after saving object to DB) field of my class .

      to get this DB generated Id so i have to query mongo Db one more time or there is some other way to do so ?

      Could you please help with above .

       

      Thanks..!

      Aniket

       

              Assignee:
              Unassigned
              Reporter:
              Aniket M
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: