-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Question mark in native query #2551
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 sounds like it needs fixing on our side. Could you provide a demonstrator, including the database using testcontainers, please? |
https://github.com/kubav182/demo-spring-data-jpa-question-mark There is demo with working JPA and JDBC implementations. Data JPA implementation does not work and test fails. |
Thanks @kubav182. I've reproduced it on my end with a very simple unit test. |
The checks for JDBC and JPA parameters were sloppy and based on side effects. By using zero width lookaheads, we can precisely spot situtations where the user has both types of parameters. Otherwise, let the query on through to the JPA provider. Closes #2551.
@kubav182 I've patched it on Spring Data JPA 3.x where it ONLY blocks you if you REALLY have mixed JDBC and JPA style parameters. Anything else and we'll let it on through to the JPA provider. See commit above for examples. |
The checks for JDBC and JPA parameters were sloppy and based on side effects. By using zero width lookaheads, we can precisely spot situtations where the user has both types of parameters. Otherwise, let the query on through to the JPA provider. Closes #2551.
The checks for JDBC and JPA parameters were sloppy and based on side effects. By using zero width lookaheads, we can precisely spot situtations where the user has both types of parameters. Otherwise, let the query on through to the JPA provider. Closes #2551.
Backported to |
Nice work, looks good. |
@kubav182 Are you able to share a little about how you've wired up Postgres, JSONB operations, your own custom queries, and what version of Spring Boot you are using to pull it all together? We are hitting another issue in the land of Postgres and JSONB operations and hitting a roadblock. |
@gregturn Sorry for late answer. We decided for another solution as we could not wait for release. I tried to upgrade my demo to Spring Boot 2.7.4 and it really does not work. I did investigation and the problem is in class
Prefix
I'm not sure about related risks. |
Any updates on this? I still can't use ? jsonb operator in a native query (postgresql) |
@razorree |
When working with jsonb type in postgres, we can use ? operator.
SELECT * FROM table WHERE (json_col->'jsonKey')::jsonb ? :param
In JDBC driver you can use escape sequence
??
In Hibernate you can use escape sequence
\\?\\?
But what should I use in Spring Data JPA? I'm getting error during startup java.lang.IllegalArgumentException: Mixing of ? parameters and other forms like ?1 is not supported!
I'm using Spring Boot 2.4.5
The text was updated successfully, but these errors were encountered: