Skip to content

Conversation

artembilan
Copy link
Member

Related to: #10083

  • Turn EntryEventMessagePayload into record. Fix access from tests, respectively
  • Extract ParameterExpressionEvaluator into a top-level class as it is expected by the ExpressionEvaluatingParameterSource

Related to: spring-projects#10083

* Turn `EntryEventMessagePayload` into `record`.
Fix access from tests, respectively
* Extract `ParameterExpressionEvaluator` into a top-level class as it is expected by the `ExpressionEvaluatingParameterSource`
Copy link
Contributor

@cppwfs cppwfs left a comment

Choose a reason for hiding this comment

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

LGTM
Just one silly question.

if (jpaParameter.getExpression() != null) {
private @Nullable Object obtainParameterValue(JpaParameter jpaParameter) {
Object value = jpaParameter.getValue();
if (value == null && jpaParameter.getExpression() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with change. Should we add this as a note, since it is a change in behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don’t think so.
I tried to keep outcome of the method the same. Semantically logic is not changed. Just perspective how the value is handled .
What do you think I have broken since it gives an impression that behavior has changed?

Copy link
Contributor

Choose a reason for hiding this comment

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

The original behavior would allow the expression to be evaluated regardless if value was null or not (and expression was not null). Now it is only evaluated if value is null and expression is not null.

I'm wondering if people built their code around the fact that they would prefer to get the result from a expression evaluation even if the value is not null.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh! I see. I thought that is else if.
Let me look into this again .
Thank you for spotting!

Copy link
Member Author

Choose a reason for hiding this comment

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

So, the contract is this:

	/**
	 * Instantiates a new Jpa Parameter without a name. This is useful for specifying
	 * positional Jpa parameters.
	 * @param value If null, the expression property must be set
	 * @param expression If null, the value property must be set
	 */
	public JpaParameter(@Nullable Object value, @Nullable String expression) {

Therefore an existing logic is wrong: we really should not go and check for getExression() if getValue() is not null.
It might rely on assumption that expression is not set, but I don't think we can rely on that.
With that I think it is better to honor that contract even more.

@cppwfs cppwfs merged commit 24f699d into spring-projects:main Aug 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants