You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying make a search based on one of my class's enum fields, but receive the following error: InvalidDataAccessApiUsageException: Parameter value [FIRST] did not match expected type [*.MY_ENUM (n/a)];
To make it clear through an example, let's say I have an entity-class "MyClass" which has a field "MY_ENUM enumField", and MY_ENUM has the values ('FIRST', 'SECOND', 'THIRD').
I am trying to query for all MyClass entries that have the value 'FIRST' in their enumField.
My HTTP request is: localhost:8080/controller/search?search=enumField:FIRST.
I have also tried putting the FIRST query param in single & double quotes but the result was the same.
I have traced the problem to Spring's org.hibernate.query.spi.QueryParameterBindingValidator, method isValidBindValue().
Method isValidBindValue() checks whether value "FIRST" is of MY_ENUM type.
More specifically, the line that effectively causes the exception is expectedType.isInstance(value), where expectedType is "class MY_ENUM" and value is "FIRST", which evaluates to false and thus the error message - values checked via Intellij's debugger.
I have tried it with versions 0.2.3 & 0.2.4 of sipios/spring-search. My Spring Boot version is 2.7.3.
I saw that version 0.2.3 should support querying enums but I couldn't find any relative examples on how to do it, so it may be possible I have misunderstood how to use spring-search.
The text was updated successfully, but these errors were encountered:
Version 0.2.4. Starting by gradle bootRun
I found the same place in QueryParameterBindingValidator.. It checks that enum value is instanceof enum type.
They are the same types, BUT! loaded with different ClassLoader's:
RestartClassLoader
Launcher$AppClassLoader
That's why it thinks they are different types.
In #21 mentioned that start by jar -jar ... is some kind of workaround
I am trying make a search based on one of my class's enum fields, but receive the following error:
InvalidDataAccessApiUsageException: Parameter value [FIRST] did not match expected type [*.MY_ENUM (n/a)];
To make it clear through an example, let's say I have an entity-class "MyClass" which has a field "MY_ENUM enumField", and MY_ENUM has the values ('FIRST', 'SECOND', 'THIRD').
I am trying to query for all MyClass entries that have the value 'FIRST' in their enumField.
My HTTP request is: localhost:8080/controller/search?search=enumField:FIRST.
I have also tried putting the FIRST query param in single & double quotes but the result was the same.
I have traced the problem to Spring's org.hibernate.query.spi.QueryParameterBindingValidator, method isValidBindValue().
Method isValidBindValue() checks whether value "FIRST" is of MY_ENUM type.
More specifically, the line that effectively causes the exception is expectedType.isInstance(value), where expectedType is "class MY_ENUM" and value is "FIRST", which evaluates to false and thus the error message - values checked via Intellij's debugger.
I have tried it with versions 0.2.3 & 0.2.4 of sipios/spring-search. My Spring Boot version is 2.7.3.
I saw that version 0.2.3 should support querying enums but I couldn't find any relative examples on how to do it, so it may be possible I have misunderstood how to use spring-search.
The text was updated successfully, but these errors were encountered: