I have a project with PostgreSQL database where queries are stored in SQL files and executed using namedParameterJdbcTemplate#queryForList method. Meaning that parameters are stored in the queries using placeholders, for example:
WHERE 1=1
and ( CAST ( rf.date AS varchar ) = :date OR 'getAll' = :date )
and ( CAST ( krr.id AS varchar ) = :id OR 'getAll' = :id )
And for passing the parameters into the query, we use a Map<String, Object>.
My question is, how can I use this mechanism to search for substrings using LIKE %something%? Trying to pass a parameter formatted like “%something%” doesn’t work, altering the query to use CONCAT with % and parameter doesn’t work either, I’m getting syntax error every time. The % sings are evidently the problem here, I can search fine without them but of course that will only result exact matches.
2