How to use a list of string in NamedParameterJDBCTemplate to get results

前端 未结 2 568
南方客
南方客 2020-12-31 00:00

Experimenting with Spring-JDBC. I am using this as reference. I am trying to get a list of actors who have the same last name. Running this code gave me the desired results:

2条回答
  •  耶瑟儿~
    2020-12-31 00:33

    You can also use MapSqlParameterSource

    String query = "SELECT FIRSTNAME FROM ACTORS WHERE LASTNAME in (:LASTNAME)";
    Set ids = ....;
    
    MapSqlParameterSource parameters = new MapSqlParameterSource();
    parameters.addValue("LASTNAME", ids);
    
    this.namedparameterJdbcTemplate.query(query, parameters);
    

提交回复
热议问题