-
Notifications
You must be signed in to change notification settings - Fork 90
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
Parameter value did not match expected type #1963
Comments
Could you please post the HQL that is generated for both cases that fails? |
Sorry for only just getting back on this, but please see HQL. If you need any further please let me know. As a fix, we have changed the searchParam to a param on the builder and referenced it using an expression. Still curious to why the original way is an issue though and whether we did something wrong. Thanks Not working (like clause happens first in exists, and conditional restrictions applied in code):
Working (with like clause moved to end of where):
Working (when conditional restrictions not applied, so like clause appears at end anyway):
|
It's kind of odd that you say the first is not working but the second one is, since the queries are equivalent. It's just that one predicate is at a different position. Could you please try creating a reproducer for this problem for me to look into e.g. based on one of our quickstarts? |
Sure will try to get this done tomorrow between things. Thanks for looking into this, drove me insane! Could it just be a bug with the parameter type checking? I did a small amount of debugging and when it didn't work the parameter for the search term ended up checking the originator parameter. Interestingly we are using an entity view with a sub entity view that has a subselect of a further list entity view. If i comment out the subselect to use the default join strategy then everything works (regardless of where the like clause is placed). Sorry my knowledge ends here as feel like this could be a bug deep in hibernate. |
Well, this could actually be a problem with the subselect strategy in entity-views. I hope that with a reproducer, I can figure this out. |
Please see attached reproducer (took me some time to actually reproduce as seems to be a very specific combination of things..). With hibernate 6.6 moving the line as per the original post no longer fixes the issue. Not sure if it helps but found that:
|
Description
Using the criteria builder with a whereExists and combination of where like, and conditionally a 'whereOr' breaks when the like condition happens first. An exception is thrown with the paramater being the wrong type.
If the like query is moved to the end of the whereExists everything work ok, so not sure if we have done something wrong with the criteria builder here...or if there is a bug with Blaze or Hibernate itself.
The error:
java.lang.IllegalArgumentException: Parameter value [%search term%] did not match expected type [java.lang.Long (n/a)]
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:54)
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:27)
at org.hibernate.query.internal.QueryParameterBindingImpl.validate(QueryParameterBindingImpl.java:90)
at org.hibernate.query.internal.QueryParameterBindingImpl.setBindValue(QueryParameterBindingImpl.java:55)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:501)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:122)
Expected behavior
Not sure why the order here matters of the like clause.
Actual behavior
Like clause causes paramater type exception if placed before other clauses with a parameter, when using whereExists.
Steps to reproduce
Code that results in error (only when condition user restrictions are applied, else works ok):
Code that works (where("v.value") line moved after the conditional user restrictions):
Environment
Version: 1.6.14
JPA-Provider: Hibernate 5.6.15.Final (but also tested on 6.6 with same issue)
DBMS: PostgreSQL 16
Application Server: Spring Boot Java 17
The text was updated successfully, but these errors were encountered: