'Filtering a table with parameters using MapSqlParameterSource
so I have a simple query like this:
SELECT id,
firstname,
lastname,
email
FROM accounts WHERE LOWER(firstname) LIKE ANY(:firstnames);
I am trying to pass the parameters such as:
public List<TestRow> queryTest(List<String> firstname) {
List<String> firstnames = new ArrayList<>();
firstname.forEach(name ->{
firstnames.add("%"+name+"%");
});
MapSqlParameterSource namedParameters = new MapSqlParameterSource();
namedParameters.addValue("firstnames", firstname);
return queryForList(QUERY_PREFIX + "test", namedParameters, TestRow.class);
}
I did try to modify the elements to '{%kaan%,%melis%}' so that LIKE ANY works but I get ERROR: syntax error at or near "," error everytime. What is my mistake? thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
