zoukankan      html  css  js  c++  java
  • mybatis嵌套map或者map嵌套的parameterType

    Spring的重要注解

    https://www.cnblogs.com/rolandlee/p/11014923.html

    一:首先是map嵌套:

    例1:

    例2:

    总结:

    paramterType无论是MAP或者是map嵌套的类型都可以,只是在取得参数时的层次不同而已:

     

     <foreach collection="batchStatus" item="item" open="(" close=")" separator=",">
                        #{item}
                    </foreach>

    二:list嵌套MAP

    sevice:

    List<Map<String, Object>> device = new ArrayList<>();
    for (int i = 0; i < 2 ; i++) {
    Map<String, Object> map = new HashMap<>();
    map.put("deviceName", "摄像头");
    map.put("logicId", 1 + i);
    device.add(map);
    }
    List<DeviceDetail> list = deviceDetailMapper.selectByNameLogicId(device);

    dao:

    List<DeviceDetail> selectByNameLogicId(List<Map<String, Object>> device);

    对应的mapper.xml:

    <select id="selectByNameLogicId" parameterType="java.util.ArrayList" resultType="DeviceDetail">
        select * from device_detail
        <where>
            (device_name,logic_id) in
            <foreach collection="list" item="item" open="(" close=")" separator=",">
                (#{item.deviceName},#{item.logicId})
            </foreach>
        </where>
    </select>

     https://blog.csdn.net/sjmuvx/article/details/79495900

    mybatis的parameterType使用map实现真正的sql随意写

    https://www.cnblogs.com/YingYue/p/4126231.html 

  • 相关阅读:
    php函数
    php循环语句(二)
    php循环语句(一)
    php魔术常量
    php超级全局变量
    php数组函数
    php数组
    php条件语句(二)
    php条件语句(一)
    shell 中的判断
  • 原文地址:https://www.cnblogs.com/leeego-123/p/11024058.html
Copyright © 2011-2022 走看看