Skip to content

Commit e86cc2f

Browse files
committed
GH-2671 - Migrate off deprecated Parameters API.
Migrate to newly introduced constructors and methods to consider the relationship between the domain type and Class<?> parameters to distinguish between projection parameters and bindable class parameters. Closes #2671
1 parent 4a2282c commit e86cc2f

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/main/java/org/springframework/data/neo4j/repository/query/Neo4jQueryMethod.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*/
1616
package org.springframework.data.neo4j.repository.query;
1717

18+
import java.lang.reflect.Method;
19+
import java.util.List;
20+
import java.util.Optional;
21+
1822
import org.springframework.core.MethodParameter;
1923
import org.springframework.core.annotation.AnnotatedElementUtils;
2024
import org.springframework.data.neo4j.repository.support.CypherdslStatementExecutor;
@@ -23,13 +27,10 @@
2327
import org.springframework.data.repository.query.Parameter;
2428
import org.springframework.data.repository.query.Parameters;
2529
import org.springframework.data.repository.query.QueryMethod;
30+
import org.springframework.data.util.TypeInformation;
2631
import org.springframework.lang.Nullable;
2732
import org.springframework.util.ClassUtils;
2833

29-
import java.lang.reflect.Method;
30-
import java.util.List;
31-
import java.util.Optional;
32-
3334
/**
3435
* Neo4j specific implementation of {@link QueryMethod}. It contains a custom implementation of {@link Parameter} which
3536
* supports Neo4js specific placeholder as well as a convenient method to return either the parameters index or name
@@ -72,7 +73,8 @@ class Neo4jQueryMethod extends QueryMethod {
7273
* @param factory must not be {@literal null}.
7374
* @param cypherBasedProjection True if this points to a Cypher-DSL based projection.
7475
*/
75-
Neo4jQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory, boolean cypherBasedProjection) {
76+
Neo4jQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
77+
boolean cypherBasedProjection) {
7678
super(method, metadata, factory);
7779

7880
Class<?> declaringClass = method.getDeclaringClass();
@@ -108,25 +110,20 @@ Optional<Query> getQueryAnnotation() {
108110
}
109111

110112
@Override
111-
protected Parameters<Neo4jParameters, Neo4jParameter> createParameters(Method method) {
112-
return new Neo4jParameters(method);
113+
protected Parameters<Neo4jParameters, Neo4jParameter> createParameters(Method method, TypeInformation<?> domainType) {
114+
return new Neo4jParameters(method, domainType);
113115
}
114116

115117
static class Neo4jParameters extends Parameters<Neo4jParameters, Neo4jParameter> {
116118

117-
Neo4jParameters(Method method) {
118-
super(method);
119+
Neo4jParameters(Method method, TypeInformation<?> domainType) {
120+
super(method, it -> new Neo4jParameter(it, domainType));
119121
}
120122

121123
private Neo4jParameters(List<Neo4jParameter> originals) {
122124
super(originals);
123125
}
124126

125-
@Override
126-
protected Neo4jParameter createParameter(MethodParameter parameter) {
127-
return new Neo4jParameter(parameter);
128-
}
129-
130127
@Override
131128
protected Neo4jParameters createFrom(List<Neo4jParameter> parameters) {
132129
return new Neo4jParameters(parameters);
@@ -139,12 +136,13 @@ static class Neo4jParameter extends Parameter {
139136
private static final String POSITION_PARAMETER_TEMPLATE = "$%d";
140137

141138
/**
142-
* Creates a new {@link Parameter} for the given {@link MethodParameter}.
139+
* Creates a new {@link Parameter} for the given {@link MethodParameter} and {@link TypeInformation}.
143140
*
144141
* @param parameter must not be {@literal null}.
142+
* @param domainType must not be {@literal null}.
145143
*/
146-
Neo4jParameter(MethodParameter parameter) {
147-
super(parameter);
144+
Neo4jParameter(MethodParameter parameter, TypeInformation<?> domainType) {
145+
super(parameter, domainType);
148146
}
149147

150148
public String getPlaceholder() {

0 commit comments

Comments
 (0)