79550681

Date: 2025-04-02 13:00:13
Score: 0.5
Natty:
Report link

I found a solution, how to make proper IN clauses in case somebody needs to search based on multiple values in a field that is from a PosgreSQL type as the John Williams's solution works BUT on Varchar field

 return jdbcClient.sql("""
                                SELECT * 
                                FROM configuration 
                                WHERE status IN (:status)
                        """)
                .param("status", request.configurationStatus().stream().map(Enum::name).collect(Collectors.toList()), OTHER)
                .query((rs, rowNum) -> parseConfiguration(rs))
                .list();

The key thing is that the third parameter should be used, which defines the SQL type

enter image description here

In my case I used OTHER (Call type can be seen from java.sql.Types)
enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
Posted by: Tsvetoslav Tsvetkov