1、List示例

java文件:

dao:

public List<ServicePort> selectByIps(List<String> ips);

xml文件:

<!-- 高级查询 -->
<select id="selectByIps" resultType="ServicePort">
Select *
from port_service_info where ip in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</select>

2、Map示例

java文件:

service:

public List<TamperAndHijack> selectByDomains(List<String> domains, String dayKey) {
Map<String, Object> map = new HashMap<String, Object>();
//不存在就查询所有
if(domains.isEmpty()){
domains = null;
}
map.put("domains", domains);
//默认为当天
if(dayKey == null || "".equals(dayKey)){
dayKey = CommonUtil.getCurrentDateStr();
}
map.put("dayKey", dayKey);
return tamperAndHijackMapper.selectByDomains(map);
}

dao:

/** 通过domains查询指纹信息 */
public List<TamperAndHijack> selectByDomains(@Param("map")Map<String, Object> map);

xml文件:

<!-- 高级查询 -->
<select id="selectByDomains" parameterType="map" resultType="TamperAndHijack">
Select *
from tamper_hijack
where 1 = 1
<if test="map.dayKey !=null and map.dayKey !=''">
and dayKey = #{map.dayKey}
</if>
<if test="map.domains !=null">
and domain in
<foreach item="item" index="index" collection="map.domains"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by id desc

</select>

mybatis传递Map和List集合示例的更多相关文章

  1. Mybatis传递多个参数的几种方式

    顺序传参法 public User selectUser(String name, int deptId); <select id="selectUser" resultMa ...

  2. MyBatis传递参数

    MyBatis传递参数 一.使用 map 接口传递参数 在 MyBatis 中允许 map 接口通过键值对传递多个参数,把接口方法定义为 : public List<Role> findR ...

  3. MyBatis多参数传递之注解方式示例--转

    原文地址:http://legend2011.blog.51cto.com/3018495/1015003 若映射器中的方法只有一个参数,则在对应的SQL语句中,可以采用#{参数名}的方式来引用此参数 ...

  4. mybatis 传递参数的方法总结

    有三种mybatis传递参数的方式: 第一种 mybatis传入参数是有序号的,可以直接用序号取得参数 User selectUser(String name,String area); 可以在xml ...

  5. mybatis传递多个参数值(转)

    Mybatis传递多个参数   ibatis3如何传递多个参数有两个方法:一种是使用Map,另一种是使用JavaBean. <!--      使用HashMap传递多个参数      para ...

  6. Mybatis传递多个参数进行SQL查询的用法

    当只向xxxMapper.xml文件中传递一个参数时,可以简单的用“_parameter”来接收xxxMapper.java传递进来的参数,并代入查询. 但是,如果在xxxMapper.java文件中 ...

  7. 手写Mybatis和Spring整合简单版示例窥探Spring的强大扩展能力

    Spring 扩展点 **本人博客网站 **IT小神 www.itxiaoshen.com 官网地址****:https://spring.io/projects/spring-framework T ...

  8. JAX-WS:背后的技术JAXB及传递Map

    转载:http://www.programgo.com/article/98912703200/ 1.什么是JAX-WS JAX-WS (JavaTM API for XML-Based Web Se ...

  9. Activity之间通过intent 传递Map

    //传递 Map<String,Object> data=orderlist.get(arg2-1); SerializableMap tmpmap=new SerializableMap ...

随机推荐

  1. iptables允许一个ip访问本机的某个端口

    需求是redis允许特定客服端连接: -A INPUT -s .xx.xx.xxx/ -p tcp --dport -j ACCEPT

  2. Oracle PLSQL Demo - 18.02.管道function[查询零散的字段组成list管道返回] [字段必须对上]

    --PACKAGE CREATE OR REPLACE PACKAGE test_141215 is TYPE type_ref IS record( ENAME ), SAL )); TYPE t_ ...

  3. Spark的性能调优

    下面这些关于Spark的性能调优项,有的是来自官方的,有的是来自别的的工程师,有的则是我自己总结的. Data Serialization,默认使用的是Java Serialization,这个程序员 ...

  4. org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xm

    org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xm 检查jar包是否正确以及配置的xm ...

  5. python--Numpy简单实用实例

    # _*_ coding:utf-8 _*_ import numpy as np #创建数组 a=np.array([[1.,7.,0.],[-2.,1.,2.]]) print a #ndarra ...

  6. SQL2005 全文检索超时的解决方案

    如果没有 Internet 连接的服务器上运行的 SQL Server 2005 实例中运行全文查询时,您可能会遇到 45 秒钟的延迟 详细的解释请查看http://support.microsoft ...

  7. Linux GPIO控制方法

    Linux GPIO控制方法 kernel version 4.4.12 在文件系统层: 1. 进入 /sys/class/gpio/ 目录 2. 假设你想控制的GPIO0_29,步骤如下: 1. e ...

  8. 轻松学习之Linux教程二 一览纵山小:Linux操作系统具体解释

    本系列文章由@uid=hpw" style="padding:0px; margin:0px; color:rgb(255,0,0); text-decoration:none&q ...

  9. expect模块的使用,主要没装包折腾一晚上

    第一步首先下载expect 模块,yum list |grep expect ,安装下面的模块. expect.x86_64                               5.44.1. ...

  10. 深入浅出Cache

    章节 ① 什么是Cache? Cache的目标? ② Caching住哪些内容? ③ 我们想要的Cache产品 ④ Cache使用方式 ⑤ 对于总体系统的提高 ⑥ 关于Sharding ⑦ Cache ...