mybatis the mapper into a plurality of transmission parameters

There are three ways

1, use placeholders # {0}, {1} .... # is the order parameter corresponding to

#方法签名
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, using the reference map enclosed in

#生成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, using @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>

 

Guess you like

Origin www.cnblogs.com/tianphone/p/10945152.html