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

org.bson.codecs.configuration.CodecConfigurationException in when update document with specified array field

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.2
    • Component/s: BSON
    • Labels:
      None

      i want to update userinfo.languages filled in this document.
      {"userInfo": {
      "fullName": "Ehsan Farahani Asil",
      "birthdate": 0,
      "aboutme": "Nothing",
      "interests": [],
      "drinking": "",
      "smoking": "",
      "languages": [

      { "name": "English", "level": "Native" }

      ,

      { "name": "Persian", "level": "Native" }

      ],
      "relationship": "",
      "sexuality": "",
      "bodyType": "",
      "eyeColor": "",
      "hairColor": "Black",
      "living": "",
      "kids": "No",
      "height": 0,
      "weight": 0,
      "work": "Software Developer"
      }
      }
      when i want to update this document with this code, mongodob java driver return error org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class project.models.base.Language.

      i use this code for update
      UpdateResult updateResult = mongoCollection.updateOne(eq("_id", new ObjectId(usersId)), Updates.set("userInfo.languages",userInfo.getLanguages()));

      public class UserInfo {
      private List<Language> languages = null;
      public List<Language> getLanguages()

      { return languages; }

      public void setLanguages(List<Language> languages)

      { this.languages = languages; }

      }

      public class Language {
      @SerializedName("name")
      private String name;
      @SerializedName("level")
      private String level;

      public String getName()

      { return name; }

      public void setName(String name)

      { this.name = name; }

      public String getLevel()

      { return level; }

      public void setLevel(String level)

      { this.level = level; }

      }

      i problem with update each field that like languages use list<> or arrayList. in other filed that use integer, Boolean, string, double i don't have any problems.

      Best Regards
      Ehsan Farahani Asil

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            ehsansis0 Ehsan Farahani Asil
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: