[JAVA-3304] @BsonProperty is necessary on getter and setter Created: 29/May/19  Updated: 30/Mar/22

Status: Backlog
Project: Java Driver
Component/s: POJO
Affects Version/s: 3.10.2
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Björn Kautler Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to JAVA-3303 @BsonProperty on a getter is ignored ... Backlog

 Description   

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.


Generated at Thu Feb 08 08:59:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.