What are the best workarounds for using a SQL IN
clause with instances of java.sql.PreparedStatement
, which is not supported for multiple values du
This worked for me (psuedocode):
public class SqlHelper
{
public static final ArrayListplatformList = new ArrayList<>(Arrays.asList("iOS","Android","Windows","Mac"));
public static final String testQuery = "select * from devices where platform_nm in (:PLATFORM_NAME)";
}
specicify binding :
public class Test extends NamedParameterJdbcDaoSupport
public List runQuery()
{
//define rowMapper to insert in object of SampleClass
final Map map = new HashMap<>();
map.put("PLATFORM_LIST",DeviceDataSyncQueryConstants.platformList);
return getNamedParameterJdbcTemplate().query(SqlHelper.testQuery, map, rowMapper)
}