DATAMONGO-2400 - Polishing.
Adapt to changes in commons. Add functional create method to MongoCustomConversions. Update Javadoc and reference documentation. Truncate precision for Java 11 build compatibility in tests. Original pull request: #810.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
[[mapping-chapter]]
|
||||
= Mapping
|
||||
|
||||
@@ -290,10 +291,8 @@ public class GeoSpatialAppConfig extends AbstractMongoClientConfiguration {
|
||||
return "com.bigbank.domain";
|
||||
}
|
||||
|
||||
// the following are optional
|
||||
|
||||
@Override
|
||||
void customConversionsConfiguration(MongoConverterConfigurationAdapter adapter) {
|
||||
void configureConverters(MongoConverterConfigurationAdapter adapter) {
|
||||
|
||||
adapter.registerConverter(new org.springframework.data.mongodb.test.PersonReadConverter());
|
||||
adapter.registerConverter(new org.springframework.data.mongodb.test.PersonWriteConverter());
|
||||
@@ -310,11 +309,12 @@ public class GeoSpatialAppConfig extends AbstractMongoClientConfiguration {
|
||||
`AbstractMongoClientConfiguration` requires you to implement methods that define a `com.mongodb.client.MongoClient` as well as provide a database name. `AbstractMongoClientConfiguration` also has a method named `getMappingBasePackage(…)` that you can override to tell the converter where to scan for classes annotated with the `@Document` annotation.
|
||||
|
||||
You can add additional converters to the converter by overriding the `customConversionsConfiguration` method.
|
||||
MongoDB's native JSR-310 support can be enabled through `MongoConverterConfigurationAdapter.useNativeDriverJavaTimeCodecs()`.
|
||||
Also shown in the preceding example is a `LoggingEventListener`, which logs `MongoMappingEvent` instances that are posted onto Spring's `ApplicationContextEvent` infrastructure.
|
||||
|
||||
NOTE: `AbstractMongoClientConfiguration` creates a `MongoTemplate` instance and registers it with the container under the name `mongoTemplate`.
|
||||
|
||||
Spring's MongoDB namespace lets you enable mapping functionality in XML, as the following example shows:
|
||||
Spring's MongoDB namespace lets you enable mapping functionality in XML, as the following example shows:
|
||||
|
||||
.XML schema to configure MongoDB mapping support
|
||||
====
|
||||
|
||||
Reference in New Issue
Block a user