diff --git a/src/main/antora/modules/ROOT/pages/keyvalue/repository/map-repositories.adoc b/src/main/antora/modules/ROOT/pages/keyvalue/repository/map-repositories.adoc index 1fe3101..56c3c40 100644 --- a/src/main/antora/modules/ROOT/pages/keyvalue/repository/map-repositories.adoc +++ b/src/main/antora/modules/ROOT/pages/keyvalue/repository/map-repositories.adoc @@ -2,7 +2,7 @@ = Map Repositories Map repositories reside on top of the `KeyValueTemplate`. -Using the default `SpelQueryCreator` allows deriving query and sort expressions from the given method name, as the following example shows: +Using the default `PredicateQueryCreator` allows deriving query and sort expressions from the given method name, as the following example shows: [source, java] ---- @@ -16,3 +16,10 @@ interface PersonRepository implements CrudRepository { List findByLastname(String lastname); } ---- + +== Configuring the QueryEngine + +It is possible to change the `QueryEngine` and use a custom one instead of the default. +The `EnableMapRepositories` annotation allows to configure the by supplying a `QueryEngineFactory` as well as the `QueryCreator` via according attributes. +Please mind that the `QueryEngine` needs to be able to process queries created by the configured `QueryCreator`. + diff --git a/src/main/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreator.java b/src/main/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreator.java index 9e3dafe..d0107e5 100644 --- a/src/main/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreator.java +++ b/src/main/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreator.java @@ -181,7 +181,7 @@ public class SpelQueryCreator extends AbstractQueryCreator queryEngineFactoryType = (Class) getAnnotationAttributes( source).get("queryEngineFactory"); - if (queryEngineFactoryType != null && !queryEngineFactoryType.isInterface()) { - - if (sortAccessor != null) { - Constructor constructor = ClassUtils - .getConstructorIfAvailable(queryEngineFactoryType, SortAccessor.class); - if (constructor != null) { - return BeanUtils.instantiateClass(constructor, sortAccessor).create(); - } - } - - return BeanUtils.instantiateClass(queryEngineFactoryType).create(); + if(queryEngineFactoryType == null || queryEngineFactoryType.isInterface()) { + return null; } - return null; + if (sortAccessor != null) { + Constructor constructor = ClassUtils + .getConstructorIfAvailable(queryEngineFactoryType, SortAccessor.class); + if (constructor != null) { + return BeanUtils.instantiateClass(constructor, sortAccessor).create(); + } + } + + return BeanUtils.instantiateClass(queryEngineFactoryType).create(); } private static Map getAnnotationAttributes(RepositoryConfigurationSource source) {