Skip to content

Commit 4d8019a

Browse files
Jay Bryantchristophstrobl
Jay Bryant
authored andcommitted
Editing pass for new content in reference documentation.
Closes: #4049
1 parent 47864e0 commit 4d8019a

File tree

2 files changed

+28
-36
lines changed

2 files changed

+28
-36
lines changed

src/main/asciidoc/reference/mongo-property-converters.adoc

+18-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[[mongo.property-converters]]
22
== Property Converters - Mapping specific fields
33

4-
While <<mongo.custom-converters, type-based conversion>> already offers ways to influence the conversion and representation of certain types within the target store it has its limitations when only certain values or properties of a particular type should be considered for conversion.
5-
Property-based converters allow configuring conversion rules on a per-property basis, either declarative, via `@ValueConverter`, or programmatic by registering a `PropertyValueConverter` for a specific property.
4+
While <<mongo.custom-converters, type-based conversion>> already offers ways to influence the conversion and representation of certain types within the target store, it has limitations when only certain values or properties of a particular type should be considered for conversion.
5+
Property-based converters allow configuring conversion rules on a per-property basis, either declaratively (via `@ValueConverter`) or programmatically (by registering a `PropertyValueConverter` for a specific property).
66

7-
A `PropertyValueConverter` can transform a given value into its store representation (**write**) and back (**read**) as shown in the snippet below.
8-
The additional `ValueConversionContext` provides additional information, such as mapping metadata and direct `read`/`write` methods.
7+
A `PropertyValueConverter` can transform a given value into its store representation (write) and back (read) as the following listing shows.
8+
The additional `ValueConversionContext` provides additional information, such as mapping metadata and direct `read` and `write` methods.
99

1010
.A simple PropertyValueConverter
1111
====
@@ -26,18 +26,18 @@ class ReversingValueConverter implements PropertyValueConverter<String, String,
2626
----
2727
====
2828

29-
`PropertyValueConverter` instances can be obtained via `CustomConversions#getPropertyValueConverter(…)` delegating to `PropertyValueConversions`, typically using a `PropertyValueConverterFactory` providing the actual converter.
30-
Depending on the applications needs, multiple instances of `PropertyValueConverterFactory` can be chained or decorated, for example to apply caching.
31-
By default, a caching implementation is used that is capable of serving types with a default constructor or enum values.
32-
A set of predefined factories is available through `PropertyValueConverterFactory` factory methods.
33-
Use `PropertyValueConverterFactory.beanFactoryAware(…)` to obtain a `PropertyValueConverter` instances from an `ApplicationContext`.
29+
You can obtain `PropertyValueConverter` instances from `CustomConversions#getPropertyValueConverter(…)` by delegating to `PropertyValueConversions`, typically by using a `PropertyValueConverterFactory` to provide the actual converter.
30+
Depending on your application's needs, you can chain or decorate multiple instances of `PropertyValueConverterFactory` -- for example, to apply caching.
31+
By default, Spring Data MongoDB uses a caching implementation that can serve types with a default constructor or enum values.
32+
A set of predefined factories is available through the factory methods in `PropertyValueConverterFactory`.
33+
You can use `PropertyValueConverterFactory.beanFactoryAware(…)` to obtain a `PropertyValueConverter` instance from an `ApplicationContext`.
3434

3535
You can change the default behavior through `ConverterConfiguration`.
3636

3737
[[mongo.property-converters.declarative]]
3838
=== Declarative Value Converter
3939

40-
The most straight forward usage of a `PropertyValueConverter` is by annotating properties with the `@ValueConverter` annotation that defines the converter type.
40+
The most straight forward usage of a `PropertyValueConverter` is by annotating properties with the `@ValueConverter` annotation that defines the converter type:
4141

4242
.Declarative PropertyValueConverter
4343
====
@@ -54,8 +54,8 @@ class Person {
5454
[[mongo.property-converters.programmatic]]
5555
=== Programmatic Value Converter Registration
5656

57-
Programmatic registration registers `PropertyValueConverter` instances for properties within an entity model using a `PropertyValueConverterRegistrar` as shown below.
58-
The difference to declarative registration is that programmatic registration happens entirely outside of the entity model.
57+
Programmatic registration registers `PropertyValueConverter` instances for properties within an entity model by using a `PropertyValueConverterRegistrar`, as the following example shows.
58+
The difference between declarative registration and programmatic registration is that programmatic registration happens entirely outside of the entity model.
5959
Such an approach is useful if you cannot or do not want to annotate the entity model.
6060

6161
.Programmatic PropertyValueConverter registration
@@ -76,25 +76,22 @@ registrar.registerConverter(Person.class, Person::getSsn())
7676
<2> Type safe variant that allows to register a converter and its conversion functions.
7777
====
7878

79-
[WARNING]
80-
====
81-
Dot-notation (such as `registerConverter(Person.class, "address.street", …)`) nagivating across properties into subdocuments is *not* supported when registering converters.
82-
====
79+
WARNING: Dot notation (such as `registerConverter(Person.class, "address.street", …)`) for nagivating across properties into subdocuments is *not* supported when registering converters.
8380

8481
[[mongo.property-converters.value-conversions]]
8582
=== MongoDB property value conversions
8683

87-
The above sections outlined the purpose an overall structure of `PropertyValueConverters`.
88-
This section will focus on MongoDB specific aspects.
84+
The preceding sections outlined the purpose an overall structure of `PropertyValueConverters`.
85+
This section focuses on MongoDB specific aspects.
8986

9087
==== MongoValueConverter and MongoConversionContext
9188

92-
`MongoValueConverter` offers a pre typed `PropertyValueConverter` interface leveraging the `MongoConversionContext`.
89+
`MongoValueConverter` offers a pre-typed `PropertyValueConverter` interface that uses `MongoConversionContext`.
9390

9491
==== MongoCustomConversions configuration
9592

96-
`MongoCustomConversions` are by default capable of handling declarative value converters depending on the configured `PropertyValueConverterFactory`.
97-
`MongoConverterConfigurationAdapter` is there to help set up programmatic value conversions or define the `PropertyValueConverterFactory` to be used.
93+
By default, `MongoCustomConversions` can handle declarative value converters, depending on the configured `PropertyValueConverterFactory`.
94+
`MongoConverterConfigurationAdapter` helps to set up programmatic value conversions or define the `PropertyValueConverterFactory` to be used.
9895

9996
.Configuration Sample
10097
====

src/main/asciidoc/reference/mongo-repositories.adoc

+10-15
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
= MongoDB Repositories
33

44
[[mongo-repo-intro]]
5-
== Introduction
6-
75
This chapter points out the specialties for repository support for MongoDB. This chapter builds on the core repository support explained in <<repositories>>. You should have a sound understanding of the basic concepts explained there.
86

97
[[mongo-repo-usage]]
@@ -292,13 +290,13 @@ NOTE: If the property criterion compares a document, the order of the fields and
292290
[[mongodb.repositories.queries.update]]
293291
=== Repository Update Methods
294292

295-
The keywords in the preceding table can also be used to create queries that identify matching documents for running updates on them.
296-
The actual update action is defined via the `@Update` annotation on the method itself as shown in the snippet below. +
297-
Please note that the naming schema for derived queries starts with `find`.
298-
Using _update_ (as in `updateAllByLastname(...)`) is only allowed in combination with `@Query`.
293+
You can also use the keywords in the preceding table to create queries that identify matching documents for running updates on them.
294+
The actual update action is defined by the `@Update` annotation on the method itself, as the following listing shows.
295+
Note that the naming schema for derived queries starts with `find`.
296+
Using `update` (as in `updateAllByLastname(...)`) is allowed only in combination with `@Query`.
299297

300-
The update is applied to *all* matching documents and it is *not* possible to limit the scope by passing in a `Page` nor using any of the <<repositories.limit-query-result,limiting keywords>>. +
301-
The return type can be either `void` or a _numeric_ type, such as `long` which holds the number of modified documents.
298+
The update is applied to *all* matching documents and it is *not* possible to limit the scope by passing in a `Page` or by using any of the <<repositories.limit-query-result,limiting keywords>>.
299+
The return type can be either `void` or a _numeric_ type, such as `long`, to hold the number of modified documents.
302300

303301
.Update Methods
304302
====
@@ -326,18 +324,15 @@ public interface PersonRepository extends CrudRepository<Person, String> {
326324
void updateAllByLastname(String lastname, int increment); <6>
327325
}
328326
----
329-
<1> The filter query for the update is derived from the method name. The update is as is and does not bind any parameters.
330-
<2> The actual increment value is defined by the _increment_ method argument that is bound to the `?1` placeholder.
331-
<3> It is possible to use SpEL for parameter binding.
327+
<1> The filter query for the update is derived from the method name. The update is "`as is`" and does not bind any parameters.
328+
<2> The actual increment value is defined by the `increment` method argument that is bound to the `?1` placeholder.
329+
<3> Use the Spring Expression Language (SpEL) for parameter binding.
332330
<4> Use the `pipeline` attribute to issue <<mongo-template.aggregation-update,aggregation pipeline updates>>.
333331
<5> The update may contain complex objects.
334332
<6> Combine a <<mongodb.repositories.queries.json-based,string based query>> with an update.
335333
====
336334

337-
[WARNING]
338-
====
339-
Repository updates do not emit persistence nor mapping lifecycle events.
340-
====
335+
WARNING: Repository updates do not emit persistence nor mapping lifecycle events.
341336

342337
[[mongodb.repositories.queries.delete]]
343338
=== Repository Delete Queries

0 commit comments

Comments
 (0)