Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ValueExpression infrastructure for query methods #3050

Closed
wants to merge 6 commits into from
Closed

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Feb 23, 2024

Introduce ValueExpressionQueryRewriter as replacement for SpelQueryContext.

Closes #3049

@@ -66,55 +81,38 @@ public ExtensionAwareQueryMethodEvaluationContextProvider(List<? extends Evaluat

Assert.notNull(extensions, "EvaluationContextExtensions must not be null");

this.delegate = new org.springframework.data.spel.ExtensionAwareEvaluationContextProvider(extensions);
this.delegate = new QueryMethodValueEvaluationContextAccessor(null, extensions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using null here for the Environment? In L:71 a new StandardEnvironment is passed on.

Comment on lines 174 to 184
parameters.stream()//
.filter(Parameter::isSpecialParameter)//
.forEach(it -> variables.put(//
StringUtils.uncapitalize(it.getType().getSimpleName()), //
arguments[it.getIndex()]));

parameters.stream()//
.filter(Parameter::isNamedParameter)//
.forEach(it -> variables.put(//
it.getName().orElseThrow(() -> new IllegalStateException("Should never occur")), //
arguments[it.getIndex()]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we put this in one stream processing instead of running over parameters twice?

Comment on lines 217 to 235
if (evaluationContext instanceof StandardEvaluationContext sec
&& rootObject instanceof Object[] parameterValues) {
sec.setVariables(collectVariables(parameters, parameterValues));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add variables for a given SimpleEvaluationContext as well?

@mp911de mp911de added this to the 3.4 M2 (2024.1.0) milestone Sep 25, 2024
@mp911de mp911de force-pushed the issue/3049 branch 3 times, most recently from bc3a03e to ba80df6 Compare September 27, 2024 12:11
Introduce ValueExpressionQueryRewriter as replacement for SpelQueryContext and QueryMethodValueEvaluationContextAccessor to encapsulate common ValueExpression functionality for Spring Data modules wanting to resolve Value Expressions in query methods.

Reduce dependencies in RepositoryFactoryBeanSupport and RepositoryFactorySupport to EvaluationContextProvider instead of QueryMethodEvaluationContextProvider to simplify dependencies.

Deprecate QueryMethodEvaluationContextProvider and its reactive variant for future removal.

Closes #3049
@mp911de mp911de force-pushed the issue/3049 branch 4 times, most recently from 414ff4f to c1d8d93 Compare October 8, 2024 13:32
… a EvaluatingValueExpressionQueryRewriter directly.
mp911de added a commit that referenced this pull request Oct 9, 2024
Introduce ValueExpressionQueryRewriter as replacement for SpelQueryContext and QueryMethodValueEvaluationContextAccessor to encapsulate common ValueExpression functionality for Spring Data modules wanting to resolve Value Expressions in query methods.

Reduce dependencies in RepositoryFactoryBeanSupport and RepositoryFactorySupport to EvaluationContextProvider instead of QueryMethodEvaluationContextProvider to simplify dependencies.

Deprecate QueryMethodEvaluationContextProvider and its reactive variant for future removal.

Closes #3049
Original pull request: #3050
@mp911de mp911de closed this Oct 9, 2024
@mp911de mp911de deleted the issue/3049 branch October 9, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
2 participants