且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

参数化查询:检查字段是否在SELECT语句中的值数组中

更新时间:2021-09-12 10:09:32

看看Spring 11.7.3 ,其中使用.

Take a look at the Spring Data Access web page, particularly section 11.7.3 where using the NamedParameterJdbcTemplate to build an 'IN' clause is covered.

例如

NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
String sql = "select * from emp where empno in (:ids)";
List idList = new ArrayList(2);
idList.add(new Long(7782));
idList.add(new Long(7788));
Map parameters = new HashMap();
parameters.put("ids", idList);
List emps = jdbcTemplate.query(sql, parameters, new EmpMapper());