-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
WHERE clause not working well with ENUM types #56
Comments
This seems to be a Hibernate error. Usually enums passed through Jinq work fine with Hibernate, so I'm not sure what the issue might be. Do you have more detailed error information from Hibernate? What did Hibernate say was the expected type and what did it think it received? |
It said something like this
I checked in the lambda expression, both the k.getStatus() and s are with Enum type. I also tried fetching a record without the where clause then compared it with the parameter like |
That seems strange. What happens when you move the Status enum to be its own top-level class instead of an inner-class? That's the only difference that I can see from my own test cases. |
Maybe making the Status enum |
Hmmmm still no luck with making it the top-level enum class.
then in this AuthKeyService:
Maybe it is the reason? |
That should be fine. But there might be a classloader issue. Have you looked at this Stack Overflow about Hibernate and enums? http://stackoverflow.com/questions/27622045/parameter-value-did-not-match-expected-type |
If that still doesn't work, you could try just dropping down to raw JPA/Hibernate there and seeing if the problem still comes up.
It's seems like a strange Hibernate issue, so I'm just suggesting random ideas. What happens if you move the |
@aVolpe I'm having some trouble switching to 5.2 (we are using 4.3) at the moment. Will definitely give it a try later. Anyway, thank you both for your time and help :) |
If the raw JPA seems to work, then I don't know what the issue could be because that should be exactly the same code that Jinq is running. The Stack Overflow solution is actually at the end of the page (it's not the first one listed). The accepted solution says there might be a classloader problem because of the way things are packaged up (it's possible to have two classes with the same name which Java thinks are different because they were loaded in different class loaders). But if the raw JPA worked for you, then that shouldn't be an issue. I don't think I'll be able to help you further with this without some sample code that exhibits the problem that I can run and debug. |
@my2iu @aVolpe Cheers. |
I don't know if this was the case for kasimmm, but I have encountered similar issue. The problem was that we had spring devtools in dependencies of our project, so what it does is it loads all third-party libraries with default ClassLoader, but all project classes with a separate ClassLoader. Removing devtools from dependencies solved the issue |
@OknoLombarda you saved me. I spent 3+ hours debugging this, and your comment fixed it! |
Hi,
I have a model with an enum property like this:
The enum field is persisted in MySQL as varchar.
When I do a search like
streamAll(em, AuthKey.class).where(k->k.getStatus() == Status.PENDING)
it works just fine.
But when I do a search using a parameter
it complains that 'Parameter value did not match expected type'
Any idea why? Thanks
The text was updated successfully, but these errors were encountered: