-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Spring data jpa works incorrectly with nativeQuery with enum param with H2 and mariadb #3790
Comments
If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
OrderRepositoryTest |
Thank you for the sample. Spring Data does not do anything different from when using a plain entityManager.createNativeQuery("SELECT * FROM order_ s WHERE s.status = :status", Order.class)
.setParameter("status", OrderStatus.FEEDBACK) |
Ok. But do you see any errors in spring code or not? Or it works fine and it is not spring project error? If it is related to spring project what exactly spring project team could help to solve this error? |
I have an entity with enum field. When I use native query with param of enum type and @Enumerated(EnumType.STRING) annotation it works incorrectly. I use spring-boot-starter-parent 3.4.2. I try to write the native sql query with parameter of enum type. And repository doesn't recognise it correctly. It works fine when I use spring data like findByStatus but it doesn't work for native queries. It gets entites with incorrect status. If you reorder enum values you will get another results. When I don't use @Enumerated(EnumType.STRING) annotation it works correctly.
https://stackoverflow.com/questions/79449411/spring-boot-works-incorrectly-with-nativequery-with-enum-param-with-h2-and-maria
The text was updated successfully, but these errors were encountered: