Skip to content

Enum not supported in query #1023

Closed as not planned
Closed as not planned
@victorherraiz-santander

Description

@victorherraiz-santander

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions