Skip to content

Enum not supported in query #1023

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

Closed
victorherraiz-santander opened this issue Aug 7, 2021 · 5 comments
Closed

Enum not supported in query #1023

victorherraiz-santander opened this issue Aug 7, 2021 · 5 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@victorherraiz-santander
Copy link

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 7, 2021
@schauder
Copy link
Contributor

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.

@schauder schauder added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 10, 2021
@spring-projects-issues
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Aug 17, 2021
@victorherraiz-santander
Copy link
Author

victorherraiz-santander commented Aug 23, 2021

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

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Aug 23, 2021
@schauder schauder added the type: bug A general bug label Mar 17, 2022
@schauder
Copy link
Contributor

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.

@schauder
Copy link
Contributor

This was fixed by #1212

@schauder schauder closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
@schauder schauder added status: duplicate A duplicate of another issue and removed type: bug A general bug status: feedback-provided Feedback has been provided labels Jul 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants