Enum not supported in query
Trying to execute the following query:
@Query(
"""
select * from bookings
where
employee_id = :employeeId and
to_date >= :from and
from_date <= :to and
slot in (:slots)
"""
)
fun findCollisionByEmployee(
employeeId: String,
to: LocalDate,
from: LocalDate,
slots: Collection<Booking.Slot>,
): Booking?
It throws with this message:
org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of Booking$Slot. Use setObject() with an explicit Types value to specify the type to use.] with root cause
I tried to use a Converter<Booking.Slot, String> but it does not get executed.
The expected result should be that queries use the same converters (e.i. enum to string) as other methods
Starter: org.springframework.boot:spring-boot-starter-data-jdbc:2.5.3
Please provide a Minimimal Reproducable Example, preferable as a Github repository. Make sure to include the database, either as an in memory database or if that is not possible using Testcontainers.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
https://github.com/victorherraiz-santander/spring-data-jdbc-issue-1023
It works with H2 but fails with postgresql, embedded or not.
Just run the provided app to get the excepcion
I couldn't run your example but I was able to create some integration tests reproducing the problem. Although I can't reproduce that it actually works with H2. It does though work with only a single argument instead of a collection.