-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Unable to do a query with a null paramater with 'contains' and 'is null' in 2.7.0 #2570
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
Comments
Possibly a duplicate of #2548? |
Yes, duplicate of #2548 |
Properly handle null values with like or contains. Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE or CONTAINS are applied. In this situation, the null needs to be condensed into an empty string and any wildcards can then be applied with expected results. Closes #2548, #2570. Supercedes: #2585. Related: #2461, #2544#
Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE or CONTAINS are applied. In this situation, the null needs to be condensed into an empty string and any wildcards can then be applied with expected results. Closes #2548, #2570. Supercedes: #2585. Related: #2461, #2544#
Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE or CONTAINS are applied. In this situation, the null needs to be condensed into an empty string and any wildcards can then be applied with expected results. Closes #2548, #2570. Supercedes: #2585. Related: #2461, #2544#
Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE or CONTAINS are applied. In this situation, the null needs to be condensed into an empty string and any wildcards can then be applied with expected results. Closes #2548, #2570. Supercedes: #2585. Related: #2461, #2544#
Resolved by the linked commit. |
@gregturn |
@dvag-joerg-winter Would like a fix too...we currently use 2.7.x but override the spring-data-bom.version property as |
Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE or CONTAINS are applied. In this situation, the null needs to be condensed into an empty string and any wildcards can then be applied with expected results. Closes #2548, #2570. Supercedes: #2585. Related: #2461, #2544#
Backported to |
@gregturn |
Looks like the issue is still present with newest spring-boot |
For Spring Boot 2.7, if you bump your app's |
@gregturn This works indeed. But forgive me for asking, if spring-boot 2.7.x is compatible with |
We works with postgresql event I don't think it change something.
This was working fine until 2.6.4 (included).
We had a query with a param that should be null.
It avoids us to use a 'like' when the optional parameter 'name' is null.
Before 2.6.4, it returned all the tables rows.
With 2.7.0, it doesn't return any row => no match
The behaviour changed for the parameter pass to the sql query.
Before : 2.6.4 (working)
With 2.7.0 (broken):
It seems that the bind value is the encapsulating instance (TypedParameterValue) instead of it's internal value, but only for String value (works with other types).
What is strange is that the QueryParameters object has a list of TypedValue (normal), and for the boolean, the value is 'null'

But for the String the value is not null but '%org.hibernate.jpa.TypedParameterValue@7eaf7a70%'

When I remove the 'contains' part in the query, the behaviour didn't change between the 2.6.4 and the 2.7.0, meaning it works fine with 2.7.0.
That seems it's the fact that the param is use in a 'contains' clause change its value instead of the binding.
This issue may linked to #2544 and #2549
The text was updated successfully, but these errors were encountered: