File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
source/fundamentals/data-formats Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,12 @@ package:
303303 field to BSON. You can include a discriminator to serialize POJOs
304304 nested within the field.
305305
306+ .. important::
307+
308+ When applying ``@BsonProperty`` to a private field, you must also add
309+ getter and setter methods for that field to serialize and customize
310+ the field name.
311+
306312 * - ``BsonExtraElements``
307313 - Specifies the POJO field on which to deserialize all elements that are
308314 not mapped to a field. The POJO field must be one of the following
@@ -348,9 +354,16 @@ several of the preceding annotations.
348354 public Product(@BsonProperty("modelName") String name) {
349355 this.name = name;
350356 }
357+
358+ public String getName() {
359+ return this.name;
360+ }
351361
352- // ...
362+ public void setName(String name) {
363+ this.name = name;
364+ }
353365
366+ // ...
354367 }
355368
356369.. _bson-annotation-convention:
@@ -378,7 +391,6 @@ The annotations in the example POJO specify the following behavior:
378391- Omit the ``relatedItems`` field and value when converting data
379392- Use the ``Product(String name)`` constructor when instantiating the POJO
380393
381-
382394.. _bsonextraelements-annotation-code-example:
383395
384396BsonExtraElements Example
You can’t perform that action at this time.
0 commit comments