SpringJdbcTemplate之namedJdbcTemplate 处理in及多条件查询的几种方式:
2017-07-26 00:00
471 查看
SpringJdbcTemplate之namedJdbcTemplate 处理in查询及多条件查询的几种方式:
第一种方式:用对象传参
第二种方式:用Map传参
应该还有其他方式,欢迎交流。。
第一种方式:用对象传参
private static final String GETGUESSPERSONSP="select datenum from scok where datenum= :updateTime and seq in(:list) "; public List<Sock> getGuessPersonSp(List<Integer> intList ,int updateTime) { SpVo vo = new SpVo(); vo.setUpdateTime(updateTime); vo.setList(list); SqlParameterSource ps=new BeanPropertySqlParameterSource(vo); final List<Sock> list= new ArrayList<Sock>(); this.getNamedJdbcTemplate().query(GETGUESSPERSONSP, ps,new RowCallbackHandler(){ [@Override](https://my.oschina.net/u/1162528) public void processRow(ResultSet rs) throws SQLException { Sock vo = new Sock(); vo.setDatenum(rs.getInt("datenum")); list.add(vo); }}); return list; }
第二种方式:用Map传参
private static final String SELECT_POINTBYUSERID = "select pointFlag from perpo where pointid=:pointID AND objectID =:objectID and userID in(:list)"; public List<AdVO> getReturnHalfPoint(List<Integer> list, int pointID, String ObjectID) { MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue("pointID", pointID); parameters.addValue("objectID", ObjectID); parameters.addValue("list", list); List<AdVO> listVO = this.getNamedJdbcTemplate().query(SELECT_POINTBYUSERID, parameters, new RowMapper<AdVO>() { [@Override](https://my.oschina.net/u/1162528) public AdVO mapRow(ResultSet rs, int rowNum) throws SQLException { AdVO point = new AdVO(); point.setPointflag(rs.getString("pointFlag")); return point; } }); return listVO; }
应该还有其他方式,欢迎交流。。
相关文章推荐
- Hibernate的条件查询的几种方式
- Spring控制器响应(action)请求的几种处理方式
- Hibernate 检索查询的几种方式(HQL,QBC,本地SQL,集成Spring等)
- Hibernate的条件查询的几种方式+查询所有的记录
- Hibernate的条件查询的几种方式
- Spring有几种事务处理方式
- Hibernate的条件查询的几种方式
- SpringBoot中Mongo查询条件是集合中的字段的处理
- oracle数据库查询语句in后面的参数个数超过1000的处理方式
- spring - JdbcTemplate条件in的SQL写法
- Hibernate 检索查询的几种方式(HQL,QBC,本地SQL,集成Spring等)
- 使用spring的JdbcTemplate进行查询的三种回调方式的比较
- SQL Server 存储过程中处理多个查询条件的几种常见写法分析,我们该用那种写法
- Spring Data JAP 多个不是必填的查询条件处理
- spring使用编程的方式进行事物处理_普通方式和jdbctemplate方式
- Spring-JDBC:在使用JdbcTemplate进行条件查询时没有返回数据,但是sql直接在数据库中执行是有数据返回的。
- Spring有几种事务处理方式?举例说明
- Hibernate的条件查询的几种方式
- Hibernate的条件查询的几种方式+查询所有的记录
- Hibernate 检索查询的几种方式(HQL,QBC,本地SQL,集成Spring等)