-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Issue with JPA Parameter binding after upgrading to spring-data-jpa 2.7.4 #2683
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
Related: #2548 |
It should fixed by #2655 |
Please check the snapshots to see if this problem is now handled properly. |
For our code base I can confirm the affected queries work again with 2.7.6-SNAPSHOT. Should this also be fixed on recent 3.0.0-SNAPSHOT? On my Jakarta EE based branch with spring-data-jpa 3.0.0-SNAPSHOT I still see a different number of results returned by the affected queries. |
@steffen-schaefer Yes, this was patched on |
Duplicates #2655. |
After Upgrading to spring boot 2.7.5 from 2.7.4, we can see that the NULL query parameters which involves "LIKE" clause are getting bound as empty strings and not as NULL. The same is bound as NULL, if the query condition is "=".
Looks like the problem is due to usage of newer spring-data-jpa version (2.7.5) in spring boot 2.7.5.
Spring boot 2.7.4 was using spring-data-jpa version -2.7.3 where everything looks fine.
For example
If the query is as below and the p_user_name is passed as NULL,
select user from User where :p_user_name is null or userName = :p_user_name
the parameter is properly getting bound as NULL ->
binding parameter [1] as [VARCHAR] - [null]
binding parameter [2] as [VARCHAR] - [null]
Whereas if the query is changed to like below
select user from User where :p_user_name is null or userName LIKE :p_user_name
the parameter is incorrectly getting bound as EMPTY Strings->
binding parameter [1] as [VARCHAR] - []
binding parameter [2] as [VARCHAR] - []
This is failing the existing functionalities in the application.
There seems to be some changes to StringQuery$LikeParameterBinding class (prepare method).
spring-data-jpa.2.7.3 is straight forward:
from spring-data-jpa-2.7.4 it uses PersistenceProvider.condense method
This Persistence Provider is returning empty string for some reason when the parameter value is NULL.
It might not have been a problem if it is just changing the parameter at the LIKE position, But as the same named parameter is used else where, the parameter value is bound as EMPTY string at all places which is creating the problem.
The text was updated successfully, but these errors were encountered: