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 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.
@Enumerated(EnumType.STRING) are JPA types and so there is nothing we can do here.
Have you tried running entityManager.createNativeQuery("SELECT * FROM order_ s WHERE s.status = :status", Order.class).setParameter("status", OrderStatus.FEEDBACK).getResultList() to inspect results?
That indicates that Hibernate is having issues with the enum translation. Please file a ticket with the Hibernate issue tracker and verify that your query arrangement is supported.
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: