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:
303
303
field to BSON. You can include a discriminator to serialize POJOs
304
304
nested within the field.
305
305
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
+
306
312
* - ``BsonExtraElements``
307
313
- Specifies the POJO field on which to deserialize all elements that are
308
314
not mapped to a field. The POJO field must be one of the following
@@ -348,9 +354,16 @@ several of the preceding annotations.
348
354
public Product(@BsonProperty("modelName") String name) {
349
355
this.name = name;
350
356
}
357
+
358
+ public String getName() {
359
+ return this.name;
360
+ }
351
361
352
- // ...
362
+ public void setName(String name) {
363
+ this.name = name;
364
+ }
353
365
366
+ // ...
354
367
}
355
368
356
369
.. _bson-annotation-convention:
@@ -378,7 +391,6 @@ The annotations in the example POJO specify the following behavior:
378
391
- Omit the ``relatedItems`` field and value when converting data
379
392
- Use the ``Product(String name)`` constructor when instantiating the POJO
380
393
381
-
382
394
.. _bsonextraelements-annotation-code-example:
383
395
384
396
BsonExtraElements Example
You can’t perform that action at this time.
0 commit comments