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

Pojo codec conversion missing id field

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: POJO
    • Labels:
      None

      {
          "_id" : 4771902,
          "upc" : "test-upc-v1",
          "reportingCategory" : {
              "id" : 14,
              "department" : "Footwear"
          }
      }
      

      My java class looks like

      public class Product {
          private Long _id;
          private String upc;
          private ReportingCategory reportingCategory;
      }
      
      public class ReportingCategory {
          private Long id;
          private String department;
      }
      

      I am using mongo pojo codec for conversion. "id" field under ReportingCategory is being returned as null. Rest every other data is available. I can see that data when I convert it into RawBsonDocument, but seems like it gets lost in pojo conversion.

      Seems like, if pojo has any member with name "id" it by defaults map it to "_id" field of mongo document. Here reporting category is sub document which has no "_id" field, and just some field which is happened to be named "id"

            Assignee:
            Unassigned Unassigned
            Reporter:
            rohit.jain Rohit Jain
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: