当前位置: 首页 > news >正文

qq空间刷赞推广网站郑州金水区做网站公司

qq空间刷赞推广网站,郑州金水区做网站公司,wordpress 媒体播放,中华南大街网站建设Mybatis传入参数类型为List作为条件进行查询 higher2017关注 2017.02.07 10:23:16字数 130阅读 5,658 表结构#xff1a; 表名称为constant 需求#xff1a; 现在想查询type为2、3的所有数据#xff08;甚至想查询type为1,2,3,4,5....,100的所有数据#xff09;并且返回…Mybatis传入参数类型为List作为条件进行查询 higher2017关注 2017.02.07 10:23:16字数 130阅读 5,658 表结构 表名称为constant 需求 现在想查询type为2、3的所有数据甚至想查询type为1,2,3,4,5....,100的所有数据并且返回的值是Mapkey为idvalue为constant类 如果采用一个一个传参的方式进行查询肯定是不行的,以下是通过Mybatis提供的foreach标签并配合in进行查询 Mapper ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.jm.dao.ConstantDaoresultMap idBaseResultMap typecom.jm.model.Constantresult columnid propertyid jdbcTypeBIGINT /result columnkey propertykey jdbcTypeVARCHAR /result columnvalue propertyvalue jdbcTypeVARCHAR /result columntype propertytype jdbcTypeINTEGER //resultMap!--此处一定要注意属性的名称是resultMap并且值为“BaseResultMap”这样就可以保证返回的Map的value是Constant的对象 --select idloadConstantByType resultMapBaseResultMapselect * from constant where type in!-- 这里要将collection属性的值标记为list不然不知道传入的参数是list separator表示分离器 item表示list中的一个元素 --foreach itemitem indexindex collectionlist open(separator, close)#{item}/foreach/select/mapperDAO import java.util.List; import java.util.Map;import org.apache.ibatis.annotations.MapKey; import org.springframework.stereotype.Repository;Repository public interface ConstantDao {/*** 注释MapKey表示表中那个字段作为Map的key* return*/MapKey(id)MapLong,Constant loadConstantByType(ListInteger type); }POJO实体类 public class Constant {private Long id;private String key;private String value;private Integer type;public String toString(){StringBuffer s new StringBuffer(Constant:{);s.append(id:).append(this.id).append(,);s.append(key:).append(this.key).append(,);s.append(value:).append(this.value).append(,);s.append(type:).append(this.type).append(});return s.toString();}public Constant() {super();// TODO Auto-generated constructor stub}public Long getId() {return id;}public void setId(Long id) {this.id id;}public String getKey() {return key;}public void setKey(String key) {this.key key null ? null : key.trim();}public String getValue() {return value;}public void setValue(String value) {this.value value null ? null : value.trim();}public Integer getType() {return type;}public void setType(Integer type) {this.type type;} }pojo中的实体类最好重写toString方法 junitTest: import java.util.Arrays; import java.util.List; import java.util.Map;import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;RunWith(SpringJUnit4ClassRunner.class) ContextConfiguration(locations { classpath:spring.xml, classpath:spring-mybatis.xml }) public class MubatisMapTest {Autowiredprivate ConstantDao constantDao;Testpublic void mapTest1() {ListInteger typeList Arrays.asList(2,3);MapLong,Constant constantMap constantDao.loadConstantByType(typeList);System.out.println(constantMap);} }最终测试结果 Paste_Image.png
http://www.pierceye.com/news/334263/

相关文章:

  • 分析影响网站排名的因素河南省住房和城乡建设厅网站文件
  • 宁城网站建设公司引流最好的推广方法
  • 辽宁省建设厅官方网站网站免费正能量直接进入浏览器下载安装
  • 怎么给公司建网站广州互联网营销师培训
  • 用阿里云做网站注意事项绵阳的网站建设公司哪家好
  • 电商网站设计工作内容深圳国际设计学院
  • 国内界面优秀的网站科技有限公司名字叫什么好
  • 网站底部悬浮代码搭建网站的主要风险
  • 长安网站建设公司常做网站首页的文件名
  • 学网站开发的能找什么工作赣州网站设计较好的公司
  • 网站建设接单微信营销软件收费排行榜
  • 佛山网站建设公司排名佛山微网站推广哪家专业
  • 招商网站建设网设备 光速东莞网站建设
  • 网站建设公司如何wordpress用多大主机
  • 东莞网站建设规范网页美工设计(第2版)素材
  • 论文 网站建设值得推荐的深圳app外包公司
  • 建网站的电脑可以换位置吗莆田建站培训
  • 外贸必看网站离职模板网
  • 内网网站建设正能量不良网站软件下载
  • 制作手机广告的网站吉林省建设厅网站评职称系统
  • 云南建设厅网站资质证书查询自动生成app
  • 柳州正规网站制作公司大连建设厅网站
  • 北京市保障房建设投资中心网站瘫痪广州大型网站建设公司排名
  • 做电池网站的引导页室内设计联盟效果图
  • 查询备案网站成绩查询系统网站开发
  • 网站后台编辑器上传不了图片建筑工程承包网app
  • wordpress多站点插件168工程信息网
  • 网站工信部备案号没有ftp wordpress
  • 家装公司网站建设网站建立网站有免费的吗
  • 网站后台添加投票系统wordpress mip改造