Skip to content

Commit 97bc6e1

Browse files
author
Chris Cho
authored
Merge pull request #52 from ccho-mongodb/DOCSP-9550-pojo-customization
DOCSP-9550 POJO customization
2 parents e9cc7fd + dcddf90 commit 97bc6e1

File tree

2 files changed

+656
-42
lines changed

2 files changed

+656
-42
lines changed

source/fundamentals/data-formats/document-data-format-pojo.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ requirements:
133133

134134

135135
1. Configure the :java-docs:`PojoCodecProvider <apidocs/bson/org/bson/codecs/pojo/PojoCodecProvider.html>`,
136-
a codec provider that provides the Codecs that define how to encode the data
137-
and on which classes to apply the Codecs. In this example, we use the
136+
In this example, we use the
138137
:java-docs:`automatic(true) <apidocs/bson/org/bson/codecs/pojo/PojoCodecProvider.Builder.html#automatic(boolean)>`
139138
setting of the :java-docs:`PojoCodecProvider.Builder <apidocs/bson/org/bson/codecs/pojo/PojoCodecProvider.Builder.html>`
140139
to apply the Codecs to any class and its properties.
@@ -228,3 +227,17 @@ When you run this code, your output should resemble the following:
228227
By default, the ``PojoCodecProvider`` omits fields in your POJO that are
229228
set to ``null``. For more information on how to specify this behavior, see
230229
our guide on :doc:`POJO Customization </fundamentals/data-formats/pojo-customization>`.
230+
231+
Summary
232+
-------
233+
234+
In this guide, we explained how to convert data between BSON and POJO fields
235+
by performing the following:
236+
237+
- Instantiate a ``PojoCodecProvider`` which contains Codecs which define how to
238+
encode/decode data between BSON and the POJO fields.
239+
- Specify the **automatic** conversion behavior for the ``PojoCodecProvider``
240+
to apply the ``Codecs`` to any class and its properties.
241+
- Add the ``PojoCodecProvider`` to a ``CodecRegistry``, and specify the
242+
registry on an instance of a ``MongoClient``, ``MongoDatabase``, or
243+
``MongoCollection``.

0 commit comments

Comments
 (0)