Skip to content

Commit 07a427c

Browse files
GH-2261 - Isolate checks for imperative and reactive query methods.
The deep scanning by `ClassUtils` whether a class has a given method triggers type resolution of some reactive types that might not be present in non-reactive applications. Therefore the check must be separated for imperative and reactive code paths.
1 parent 27679af commit 07a427c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.core.MethodParameter;
2323
import org.springframework.core.annotation.AnnotatedElementUtils;
2424
import org.springframework.data.neo4j.repository.support.CypherdslStatementExecutor;
25-
import org.springframework.data.neo4j.repository.support.ReactiveCypherdslStatementExecutor;
2625
import org.springframework.data.projection.ProjectionFactory;
2726
import org.springframework.data.repository.core.RepositoryMetadata;
2827
import org.springframework.data.repository.query.Parameter;
@@ -61,12 +60,24 @@ class Neo4jQueryMethod extends QueryMethod {
6160
* @param factory must not be {@literal null}.
6261
*/
6362
Neo4jQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
63+
this(method, metadata, factory, ClassUtils.hasMethod(CypherdslStatementExecutor.class, method));
64+
}
65+
66+
/**
67+
* Allows to configure {@link #cypherBasedProjection} from inheriting classes. Not meant to be called outside the
68+
* inheritance tree.
69+
*
70+
* @param method must not be {@literal null}.
71+
* @param metadata must not be {@literal null}.
72+
* @param factory must not be {@literal null}.
73+
* @param cypherBasedProjection True if this points to a Cypher-DSL based projection.
74+
*/
75+
Neo4jQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory, boolean cypherBasedProjection) {
6476
super(method, metadata, factory);
6577

6678
Class<?> declaringClass = method.getDeclaringClass();
6779
this.repositoryName = declaringClass.getName();
68-
this.cypherBasedProjection = ClassUtils.hasMethod(CypherdslStatementExecutor.class, method) || ClassUtils
69-
.hasMethod(ReactiveCypherdslStatementExecutor.class, method);
80+
this.cypherBasedProjection = cypherBasedProjection;
7081
this.queryAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, Query.class);
7182
}
7283

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.springframework.data.domain.Page;
2222
import org.springframework.data.domain.Pageable;
2323
import org.springframework.data.domain.Slice;
24+
import org.springframework.data.neo4j.repository.support.ReactiveCypherdslStatementExecutor;
2425
import org.springframework.data.projection.ProjectionFactory;
2526
import org.springframework.data.repository.core.RepositoryMetadata;
2627
import org.springframework.data.repository.util.ReactiveWrappers;
@@ -54,7 +55,7 @@ final class ReactiveNeo4jQueryMethod extends Neo4jQueryMethod {
5455
* @param factory must not be {@literal null}.
5556
*/
5657
ReactiveNeo4jQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
57-
super(method, metadata, factory);
58+
super(method, metadata, factory, ClassUtils.hasMethod(ReactiveCypherdslStatementExecutor.class, method));
5859

5960
if (org.springframework.data.repository.util.ClassUtils.hasParameterOfType(method, Pageable.class)) {
6061

0 commit comments

Comments
 (0)