zoukankan      html  css  js  c++  java
  • mybatis中mapper传多个入参

    有三种方式

    1、使用占位符#{0},#{1}....对应顺序就是参数的顺序

    复制代码
    #方法签名
    List<TbItem> selectByPage(int page, int rows);
    
    #sql语句
    <select id="selectByPage" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        from tb_item LIMIT #{0} , #{1}
      </select>
    复制代码

    2、使用map封装入参

    复制代码
    #生成map入参
    public List<TbItem> getItemByPage(int page , int rows){
            Map paramMap = new HashMap();
            paramMap.put("page",page);
            paramMap.put("rows" , rows);
            List<TbItem> tbItems = tbItemMapper.selectByPage(paramMap);
            return tbItems;
        }
    
    #sql
    <select id="selectByPage" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        from tb_item LIMIT #{page} , #{rows}
      </select>
    复制代码

    3、使用@Param

    复制代码
    #mapper中接口的签名
    List<TbItem> selectByPage(@Param("page") int page , @Param("rows") int rows);
    
    #sql
    <select id="selectByPage" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        from tb_item LIMIT #{page} , #{rows}
      </select>
    复制代码
  • 相关阅读:
    DNS bind9安装
    DHCP服务器
    RAID
    LVM
    box-pack
    display:flex和display:box布局浏览器兼容性分析
    Flex布局
    几种常见的浏览器以及内核
    display 垂直居中
    font-family 定义的最后为什么要加一句sans-serif
  • 原文地址:https://www.cnblogs.com/brithToSpring/p/13475837.html
Copyright © 2011-2022 走看看