Skip to content

Commit 485f0e7

Browse files
committed
DATAES-221 - Adapted to API changes in Spring Data Commons.
Related ticket: DATACMNS-89.
1 parent aa9c475 commit 485f0e7

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/main/java/org/springframework/data/elasticsearch/repository/query/ElasticsearchQueryMethod.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919

2020
import org.springframework.core.annotation.AnnotationUtils;
2121
import org.springframework.data.elasticsearch.annotations.Query;
22+
import org.springframework.data.projection.ProjectionFactory;
2223
import org.springframework.data.repository.core.RepositoryMetadata;
2324
import org.springframework.data.repository.query.QueryMethod;
2425
import org.springframework.util.StringUtils;
@@ -28,26 +29,23 @@
2829
*
2930
* @author Rizwan Idrees
3031
* @author Mohsin Husen
32+
* @author Oliver Gierke
3133
*/
3234
public class ElasticsearchQueryMethod extends QueryMethod {
3335

34-
private Method method;
36+
private final Query queryAnnotation;
3537

36-
public ElasticsearchQueryMethod(Method method, RepositoryMetadata metadata) {
37-
super(method, metadata);
38-
this.method = method;
38+
public ElasticsearchQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
39+
super(method, metadata, factory);
40+
this.queryAnnotation = method.getAnnotation(Query.class);
3941
}
4042

4143
public boolean hasAnnotatedQuery() {
42-
return getQueryAnnotation() != null;
44+
return this.queryAnnotation != null;
4345
}
4446

4547
public String getAnnotatedQuery() {
46-
String query = (String) AnnotationUtils.getValue(getQueryAnnotation(), "value");
48+
String query = (String) AnnotationUtils.getValue(queryAnnotation, "value");
4749
return StringUtils.hasText(query) ? query : null;
4850
}
49-
50-
private Query getQueryAnnotation() {
51-
return this.method.getAnnotation(Query.class);
52-
}
5351
}

src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactory.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery;
2626
import org.springframework.data.elasticsearch.repository.query.ElasticsearchQueryMethod;
2727
import org.springframework.data.elasticsearch.repository.query.ElasticsearchStringQuery;
28+
import org.springframework.data.projection.ProjectionFactory;
2829
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
2930
import org.springframework.data.repository.core.NamedQueries;
3031
import org.springframework.data.repository.core.RepositoryInformation;
@@ -90,11 +91,16 @@ protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key
9091
}
9192

9293
private class ElasticsearchQueryLookupStrategy implements QueryLookupStrategy {
93-
94+
95+
/*
96+
* (non-Javadoc)
97+
* @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.projection.ProjectionFactory, org.springframework.data.repository.core.NamedQueries)
98+
*/
9499
@Override
95-
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries) {
100+
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
101+
NamedQueries namedQueries) {
96102

97-
ElasticsearchQueryMethod queryMethod = new ElasticsearchQueryMethod(method, metadata);
103+
ElasticsearchQueryMethod queryMethod = new ElasticsearchQueryMethod(method, metadata, factory);
98104
String namedQueryName = queryMethod.getNamedQueryName();
99105

100106
if (namedQueries.hasQuery(namedQueryName)) {

0 commit comments

Comments
 (0)