Adopt to deprecated QueryMethod constructor.

Closes #3833
This commit is contained in:
Mark Paluch
2025-04-09 12:04:23 +02:00
parent 4f995849d0
commit de1d6a1c72
2 changed files with 22 additions and 24 deletions

View File

@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationUtils;
@@ -91,15 +92,30 @@ public class JpaQueryMethod extends QueryMethod {
/**
* Creates a {@link JpaQueryMethod}.
*
* @param method must not be {@literal null}
* @param metadata must not be {@literal null}
* @param factory must not be {@literal null}
* @param extractor must not be {@literal null}
* @param method must not be {@literal null}.
* @param metadata must not be {@literal null}.
* @param factory must not be {@literal null}.
* @param extractor must not be {@literal null}.
*/
public JpaQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
QueryExtractor extractor) {
this(method, metadata, factory, extractor, JpaParameters::new);
}
super(method, metadata, factory);
/**
* Creates a {@link JpaQueryMethod}.
*
* @param method must not be {@literal null}.
* @param metadata must not be {@literal null}.
* @param factory must not be {@literal null}.
* @param extractor must not be {@literal null}.
* @param parametersFunction function to obtain {@link JpaParameters}, must not be {@literal null}.
* @since 3.5
*/
public JpaQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
QueryExtractor extractor, Function<ParametersSource, JpaParameters> parametersFunction) {
super(method, metadata, factory, parametersFunction);
Assert.notNull(method, "Method must not be null");
Assert.notNull(extractor, "Query extractor must not be null");
@@ -413,11 +429,6 @@ public class JpaQueryMethod extends QueryMethod {
return targetType.cast(AnnotationUtils.getValue(annotation, attribute));
}
@Override
protected Parameters<?, ?> createParameters(ParametersSource parametersSource) {
return new JpaParameters(parametersSource);
}
@Override
public JpaParameters getParameters() {
return (JpaParameters) super.getParameters();

View File

@@ -92,19 +92,6 @@ class CustomNonBindableJpaParametersIntegrationTests {
}
private static class NonBindableAwareJpaQueryMethod extends JpaQueryMethod {
NonBindableAwareJpaQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
QueryExtractor extractor) {
super(method, metadata, factory, extractor);
}
@Override
protected JpaParameters createParameters(ParametersSource source) {
return new NonBindableAwareJpaParameters(source);
}
}
private static class NonBindableAwareJpaQueryMethodFactory implements JpaQueryMethodFactory {
private final QueryExtractor extractor;
@@ -115,7 +102,7 @@ class CustomNonBindableJpaParametersIntegrationTests {
@Override
public JpaQueryMethod build(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
return new NonBindableAwareJpaQueryMethod(method, metadata, factory, extractor);
return new JpaQueryMethod(method, metadata, factory, extractor, NonBindableAwareJpaParameters::new);
}
}