I have a query and a few parameters as follows,
String query = "SELECT * FROM table_name ORDER BY ? LIMIT ? ";
//I am creating this 'sortString' on runtime based on some user inputs
String sortString = " column1 ASC, column 2 ASC ";
int count =5;
I am calling the jdbcTemplate method as follows,
List<Map<String, Object>> rows = getJdbcTemplate().queryForList(query, sortString, count);
The query that is actually used by the jdbcTemplate is as follows,
SELECT * FROM table_name ORDER BY ' column1 ASC, column 2 ASC ' LIMIT 5
Now, the ORDER BY clause does not works since the criteria is put up inside ' ' by jdbcTemplate. How can I add the string to the query without the jdbcTemplate adding the " ' " by default.
I want the query to be,
SELECT * FROM table_name ORDER BY column1 ASC, column 2 ASC LIMIT 5