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
Add support for mapping document fields with . (dot) in the field name.
This commit introduces support for mapping (read/write) fields that contain dots in their name, preserving the name as is instead of considering the dot being a deliminator within a path of nested objects.
Query and Update functionality remains unaffected which means no automatic rewrite for field names containing paths will NOT take place. It's in the users responsibility to pick the appropriate query/update operator (eg. $expr) to interact with the field.
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java
@@ -244,6 +245,16 @@ public void setMapKeyDotReplacement(@Nullable String mapKeyDotReplacement) {
244
245
this.mapKeyDotReplacement = mapKeyDotReplacement;
245
246
}
246
247
248
+
/**
249
+
* If {@link #preserveMapKeys(boolean) preserve} is set to {@literal true} the conversion will treat map keys containing {@literal .} (dot) characters as is.
250
+
*
251
+
* @since 4.2
252
+
* @see #setMapKeyDotReplacement(String)
253
+
*/
254
+
publicvoidpreserveMapKeys(booleanpreserve) {
255
+
setMapKeyDotReplacement(preserve ? "." : null);
256
+
}
257
+
247
258
/**
248
259
* Configure a {@link CodecRegistryProvider} that provides native MongoDB {@link org.bson.codecs.Codec codecs} for
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/BasicMongoPersistentProperty.java
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/CachingMongoPersistentProperty.java
0 commit comments