@@ -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<Person, String> {
|
||||
List<Person> 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`.
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ public class SpelQueryCreator extends AbstractQueryCreator<KeyValueQuery<SpelExp
|
||||
case EXISTS:
|
||||
default:
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
String.format("Found invalid part '%s' in query", part.getType()));
|
||||
"Found invalid part '%s' in query".formatted(part.getType()));
|
||||
}
|
||||
|
||||
if (partIter.hasNext()) {
|
||||
|
||||
@@ -109,20 +109,19 @@ public class MapRepositoryConfigurationExtension extends KeyValueRepositoryConfi
|
||||
Class<? extends QueryEngineFactory> queryEngineFactoryType = (Class<? extends QueryEngineFactory>) getAnnotationAttributes(
|
||||
source).get("queryEngineFactory");
|
||||
|
||||
if (queryEngineFactoryType != null && !queryEngineFactoryType.isInterface()) {
|
||||
|
||||
if (sortAccessor != null) {
|
||||
Constructor<? extends QueryEngineFactory> 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<? extends QueryEngineFactory> constructor = ClassUtils
|
||||
.getConstructorIfAvailable(queryEngineFactoryType, SortAccessor.class);
|
||||
if (constructor != null) {
|
||||
return BeanUtils.instantiateClass(constructor, sortAccessor).create();
|
||||
}
|
||||
}
|
||||
|
||||
return BeanUtils.instantiateClass(queryEngineFactoryType).create();
|
||||
}
|
||||
|
||||
private static Map<String, Object> getAnnotationAttributes(RepositoryConfigurationSource source) {
|
||||
|
||||
Reference in New Issue
Block a user