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

@BsonProperty is necessary on getter and setter

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.10.2
    • Component/s: POJO
    • Labels:
      None

      The following code:

      @BsonProperty("07")
      public long getCoin07() {
          return get07();
      }
      
      public void setCoin07(long _07) {
          set07(_07);
      }
      

      will make the property coin07 serialize as 07, but on deserializing the property is ignored.
      Imho the setter should be used as the getter is annotated accordingly.
      If some other setter is annotated with @BsonProperty("07"), it could be used as explicitly configured, but as long as that annotation is not present on any setter, I'd expect the matching setter be used automatically.

      Just as clarification, there is no `coin07` field that could be annotated.
      Annotating the setter too with said annotation makes it work properly.

            Assignee:
            Unassigned Unassigned
            Reporter:
            vampire Björn Kautler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: