Pergunta

NamedParameterJdbcTemplate  namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("STR_REF",(String)strRefkeys);

    String sql = "SELECT TAGDESCRIPTION FROM xx, xx WHERE localeid='en_US' AND " +
            "xx.TAGID=xx.RECORDID and TAGDESCRIPTION is not null AND xx.REFERENCEKEY in (:STR_REF)";

List<String> ifCurrent = namedParameterJdbcTemplate.queryForList(sql, params,String.class);

not getting any results in ifCurrent although run same query as SQL query and get results.

Am I passing any wrong params?

This is what is getting passed in strRefkeys

for(String refStr : strRefkeysLst) {
        strRefkeysBuf.append("'");
        strRefkeysBuf.append(refStr.toUpperCase());
        strRefkeysBuf.append("',"); 
    }

    strRefkeys = strRefkeysBuf.toString();
    if(strRefkeys.trim().length()>1){strRefkeys  = strRefkeys.substring(0, strRefkeys.length()-1);}
Foi útil?

Solução

You're passing a string parameter where a collection of values is expected. strRefKeys should be a set of accepted values for the REFERENCEKEY column.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top