You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/mongo-property-converters.adoc
+18-21
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
[[mongo.property-converters]]
2
2
== Property Converters - Mapping specific fields
3
3
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).
6
6
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.
9
9
10
10
.A simple PropertyValueConverter
11
11
====
@@ -26,18 +26,18 @@ class ReversingValueConverter implements PropertyValueConverter<String, String,
26
26
----
27
27
====
28
28
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`.
34
34
35
35
You can change the default behavior through `ConverterConfiguration`.
36
36
37
37
[[mongo.property-converters.declarative]]
38
38
=== Declarative Value Converter
39
39
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:
41
41
42
42
.Declarative PropertyValueConverter
43
43
====
@@ -54,8 +54,8 @@ class Person {
54
54
[[mongo.property-converters.programmatic]]
55
55
=== Programmatic Value Converter Registration
56
56
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.
59
59
Such an approach is useful if you cannot or do not want to annotate the entity model.
<2> Type safe variant that allows to register a converter and its conversion functions.
77
77
====
78
78
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.
83
80
84
81
[[mongo.property-converters.value-conversions]]
85
82
=== MongoDB property value conversions
86
83
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.
89
86
90
87
==== MongoValueConverter and MongoConversionContext
91
88
92
-
`MongoValueConverter` offers a pretyped `PropertyValueConverter` interface leveraging the `MongoConversionContext`.
89
+
`MongoValueConverter` offers a pre-typed `PropertyValueConverter` interface that uses `MongoConversionContext`.
93
90
94
91
==== MongoCustomConversions configuration
95
92
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.
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/mongo-repositories.adoc
+10-15
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,6 @@
2
2
= MongoDB Repositories
3
3
4
4
[[mongo-repo-intro]]
5
-
== Introduction
6
-
7
5
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.
8
6
9
7
[[mongo-repo-usage]]
@@ -292,13 +290,13 @@ NOTE: If the property criterion compares a document, the order of the fields and
292
290
[[mongodb.repositories.queries.update]]
293
291
=== Repository Update Methods
294
292
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`.
299
297
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.
0 commit comments