DATAMONGO-2542 - Shortcut PersistentPropertyPath resolution during query mapping.

By shortcutting the path resolution we avoid checking keywords like $in against a potential path expression.

Original pull request: #863.
This commit is contained in:
Christoph Strobl
2020-05-12 09:39:38 +02:00
committed by Mark Paluch
parent 68de8e57be
commit 44cc0dad94

View File

@@ -965,7 +965,7 @@ public class QueryMapper {
this.entity = entity;
this.mappingContext = context;
this.path = getPath(removePlaceholders(POSITIONAL_PARAMETER_PATTERN, name));
this.path = getPath(removePlaceholders(POSITIONAL_PARAMETER_PATTERN, name), property);
this.property = path == null ? property : path.getLeafProperty();
this.association = findAssociation();
}
@@ -1079,11 +1079,17 @@ public class QueryMapper {
* @return
*/
@Nullable
private PersistentPropertyPath<MongoPersistentProperty> getPath(String pathExpression) {
private PersistentPropertyPath<MongoPersistentProperty> getPath(String pathExpression,
MongoPersistentProperty sourceProperty) {
String rawPath = removePlaceholders(POSITIONAL_OPERATOR,
removePlaceholders(DOT_POSITIONAL_PATTERN, pathExpression));
if (sourceProperty != null && sourceProperty.getOwner().equals(entity)) {
return mappingContext
.getPersistentPropertyPath(PropertyPath.from(sourceProperty.getName(), entity.getTypeInformation()));
}
PropertyPath path = forName(rawPath);
if (path == null || isPathToJavaLangClassProperty(path)) {
return null;