diff --git a/pom.xml b/pom.xml
index a67ad87168..9c7ed1366b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 4.3.0-SNAPSHOT
+ 4.3.x-4510-SNAPSHOT
pom
Spring Data MongoDB
diff --git a/spring-data-mongodb-benchmarks/pom.xml b/spring-data-mongodb-benchmarks/pom.xml
index 34d95eb205..473381168b 100644
--- a/spring-data-mongodb-benchmarks/pom.xml
+++ b/spring-data-mongodb-benchmarks/pom.xml
@@ -7,7 +7,7 @@
org.springframework.data
spring-data-mongodb-parent
- 4.3.0-SNAPSHOT
+ 4.3.x-4510-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml
index 124a6bf5ad..81adb719cd 100644
--- a/spring-data-mongodb-distribution/pom.xml
+++ b/spring-data-mongodb-distribution/pom.xml
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-mongodb-parent
- 4.3.0-SNAPSHOT
+ 4.3.x-4510-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml
index e7282be0fa..30e7b9f714 100644
--- a/spring-data-mongodb/pom.xml
+++ b/spring-data-mongodb/pom.xml
@@ -13,7 +13,7 @@
org.springframework.data
spring-data-mongodb-parent
- 4.3.0-SNAPSHOT
+ 4.3.x-4510-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConversionContext.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConversionContext.java
index 5172746cc5..c1a478fa77 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConversionContext.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConversionContext.java
@@ -32,19 +32,19 @@
public class MongoConversionContext implements ValueConversionContext {
private final PropertyValueProvider accessor; // TODO: generics
- private final MongoPersistentProperty persistentProperty;
+ private final @Nullable MongoPersistentProperty persistentProperty;
private final MongoConverter mongoConverter;
- @Nullable
- private final SpELContext spELContext;
+ @Nullable private final SpELContext spELContext;
public MongoConversionContext(PropertyValueProvider accessor,
- MongoPersistentProperty persistentProperty, MongoConverter mongoConverter) {
+ @Nullable MongoPersistentProperty persistentProperty, MongoConverter mongoConverter) {
this(accessor, persistentProperty, mongoConverter, null);
}
public MongoConversionContext(PropertyValueProvider accessor,
- MongoPersistentProperty persistentProperty, MongoConverter mongoConverter, @Nullable SpELContext spELContext) {
+ @Nullable MongoPersistentProperty persistentProperty, MongoConverter mongoConverter,
+ @Nullable SpELContext spELContext) {
this.accessor = accessor;
this.persistentProperty = persistentProperty;
@@ -54,12 +54,17 @@ public MongoConversionContext(PropertyValueProvider acc
@Override
public MongoPersistentProperty getProperty() {
+
+ if (persistentProperty == null) {
+ throw new IllegalStateException("No underlying MongoPersistentProperty available");
+ }
+
return persistentProperty;
}
@Nullable
public Object getValue(String propertyPath) {
- return accessor.getPropertyValue(persistentProperty.getOwner().getRequiredPersistentProperty(propertyPath));
+ return accessor.getPropertyValue(getProperty().getOwner().getRequiredPersistentProperty(propertyPath));
}
@Override
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java
index fe6cb26311..2e03627474 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java
@@ -15,8 +15,17 @@
*/
package org.springframework.data.mongodb.core.convert;
-import java.util.*;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -27,6 +36,7 @@
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;
+
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.annotation.Reference;
@@ -76,6 +86,7 @@
* @author Mark Paluch
* @author David Julia
* @author Divya Srivastava
+ * @author Gyungrai Wang
*/
public class QueryMapper {
@@ -449,65 +460,14 @@ protected Object getMappedValue(Field documentField, Object sourceValue) {
if (documentField.getProperty() != null
&& converter.getCustomConversions().hasValueConverter(documentField.getProperty())) {
- MongoConversionContext conversionContext = new MongoConversionContext(new PropertyValueProvider<>() {
- @Override
- public T getPropertyValue(MongoPersistentProperty property) {
- throw new IllegalStateException("No enclosing property available");
- }
- }, documentField.getProperty(), converter);
PropertyValueConverter