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

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

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 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

      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 Unassigned
            Reporter:
            aniket20365@gmail.com Aniket M
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: