第一种:单个参数[基本类型]:
# Mapper 接口定义
T selectByPrimaryKey(String sid);
# Mapper 映射文件
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ***
where sid = #{sid,jdbcType=VARCHAR}
</select>
第二种:多个参数
# Mapper 接口定义
public List<T> getList(String sid, String code);
# Mapper 映射文件
<select id="getList" resultType="T">
select * from ** where sid = #{0} and code= #{1}
</select>
第三种:Map参数
# Mapper 接口定义
List<T> selectAll(Map<String,Object> parame);
# Mapper 映射文件
<select id="selectAll" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from cm
where 1 = 1
<if test="id != null">
and cm.id = #{id,jdbcType=DECIMAL}
</if>
<if test="carDeptName != null">
and cm.car_dept_name = #{carDeptName,jdbcType=VARCHAR}
</if>
<if test="carMakerName != null">
and cm.car_maker_name = #{carMakerName,jdbcType=VARCHAR}
</if>
<if test="hotType != null" >
and cm.hot_type = #{hotType,jdbcType=BIGINT}
</if>
</select>
第四种:类参数
<update id="updateByPrimaryKeySelective" parameterType="com.system.model.User" >
update user
<set >
<if test="carDeptName != null" >
car_dept_name = #{carDeptName,jdbcType=VARCHAR},
</if>
<if test="carMakerName != null" >
car_maker_name = #{carMakerName,jdbcType=VARCHAR},
</if>
<if test="icon != null" >
icon = #{icon,jdbcType=VARCHAR},
</if>
<if test="carMakerPy != null" >
car_maker_py = #{carMakerPy,jdbcType=VARCHAR},
</if>
<if test="hotType != null" >
hot_type = #{hotType,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
第五种:List参数
<delete id="batchdelete" parameterType="java.util.List">
delete from user_relation_role where SID in
<foreach item="sid" collection="list" open="(" separator="," close=")">
#{sid}
</foreach>
</delete>
第七种:@Param参数
# Mapper 接口定义
List<String> selectIdBySortTime(@Param(value="startdate")String startDate);
# Mapper 映射文件
<select id="selectIdBySortTime" resultType="java.lang.String" parameterType="java.lang.String">
select distinct *** from *** where sorttime >= to_date(#{startdate,jdbcType=VARCHAR},'YYYY-MM-DD') and created_date=updated_date
and keyvalue in (select distinct companyname from *** where isupdate='0')
</select>