mybatis 复杂传参

1基本传参数

Public User selectUserWithCon(@param(userName)String  name,@param(userArea)String area);

对应的Mapper.xml

<select id=" selectUser" resultMap="BaseResultMap">

   select  *  from user  where user_name = #{userName} and user_area=#{userArea}

</select>

2 List封装in

public List<Pojo> getList(List<int> list);  

<select id="getList" resultType="Pojo">

  select 字段... from XXX where id in

  <foreach item="item" index="index" collection="list" open="(" separator="," close=")">  

    #{item}  

  </foreach>  

</select>  

3 Map封装多参数:  

public List<Pojo> geList(HashMap map);  

<select id="geList" parameterType="java.util.HashMap" resultType="Pojo">

    <!--xxId mapkey-->

select 字段... from XXX where id=#{xxId}

</select>  

 4只返回id

<select id="getChildIdByPid" resultType="java.lang.Integer">
select id from content_category where parent_id=#{0};
</select>

原文地址:https://www.cnblogs.com/javabigdata/p/5686665.html