-
Notifications
You must be signed in to change notification settings - Fork 1.5k
JPA Query with like and concat fails dependening on the initial invocation order (Spring Boot 3.1.5) #3205
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
This is because we restricted The ticket we decided to introduce Discussion about
With a construction of As transformation of JPQL into SQL is also something that the underlying JPA provider does, I would ask you to file a ticket with Hibernate. I'm sorry that this is quite frustrating. |
Hi @mp911de , thanks for your fast reply. I think / I hope I can work with the |
We actually do not want to know what the query is doing, TBCH. We have parsers for JPQL, but these serve the purpose of deriving count queries or appending sort clauses. If we wanted to detect parameter usage within functions, then we would introduce a lot of complexity that we do not want to maintain. I wish there would be an easier way out. |
@mp911de Thanks a lot for your explanation! Didn't know why you're parsing the queries (and why not). |
After discussing with our team, we will stick to the guidance provided by the Hibernate team to not use |
I have a JPA query that uses
like
together withconcat
. In Spring Boot 3.1.4 the query works fine, but starting with Spring Boot 3.1.5 it sometimes does not work anymore, and it seems it depends on the order it is executed.The repository method:
When the first call (after booting the application) to
findWithTitle
has the parametert
set tonull
, I receive the following postgres error:Susequent calls to
findWithTitle
withnull
as parameter then all fail, while calls with aString
as parameter work as expected:But when the application started and the first call to
findWithTitle
has set aString
as parametert
, subsequent calls withnull
also are working:(btw: I think the same problem occus when using
lower
instead ofconcat
in the query).If I add (as suggested by the error message) a cast in the query, it also works:
(IntelliJ IDEA marks this as syntax error, so I'm not sure, if this should be valid query string or not, but it works)
You can find a reproducable test case here: https://github.com/nilshartmann/spring-jpa-concat
Please refer to the
README.md
file on how you can run the tests isolated using maven so that one fails and the other not, depending on the invocation order offindWithTitle
.The text was updated successfully, but these errors were encountered: