1.通过序号传参
Dao层代码:
Public User selectUser(Map paramMap);
对应的Mapper.xml的代码:
<select id="selectUser" resultMap="BaseResultMap">
select * from user where user_name = #{0} and user_area=#{1}
</select>
2.通过map传参
Dao层代码:
Public User selectUser(Map paramMap);
对应的Mapper.xml的代码:
<select id=" selectUser" resultMap="BaseResultMap">
select * from user where user_name = #{userName,jdbcType=VARCHAR} and user_area=#{userArea,jdbcType=VARCHAR}
</select>
3.用@Param通过单个参数名传递参数
Dao层代码:
public boolean modifyEnd(@Param("end")String end,@Param("id")Integer id);
对应的Mapper.xml的代码:
<update id="modifyEnd">
update calendar set end = #{end} where id = #{id}
</update>
4.传递对象类型的参数
Dao层的代码:
public boolean modify(Calendar calendar);
对应的Mapper.xml的代码:
<update id="modify" parameterType="Calendar">
update calendar set title = #{title}, start = #{start}, end = #{end}, allDay = #{allDay}, color = #{color} where id = #{id}
</update>