java - How to send List of dates as part of sql query using SpringTemplate + JDBCTemplate -
well, have query :
select * table somedate in (date1, date2, date3); i trying construct using st (springtemplate) , using jdbctemplate make query.
if have pass 1 date, can use :
stringtemplateinstance.add("somecolkey",dateinstance); but how can send list of dates in clause gets it?.
right now, using stringutils.collectiontocommadelimitedstring(datelistforquery); query ( don't like).
ditch both stringtemplate jdbctemplate , switch namedparameterjdbctemplate.
string query = "select * table somedate in (:dates)"; map<string, object> params = new hashmap<string, object>(); params.put("dates", yourlistofdates); list<yourresulttype> result = template.query(query, params, new yourresulttyperowmapper()); that all.
Comments
Post a Comment