1、可以放入Map里面带过去,如:
service:
HashMap< String, String> map=new HashMap<String, String>();
map.put("id", user.getId());
map.put("pwd", newpwd);
int a=dao.upPwd(map);
dao:
int upPwd(HashMap<String, String> map);
<!--修改密码-->
<update id="upPwd" parameterType="Map">update user set pwd=#{pwd} where id=#{id}</update>
2、可以加@Param注解,如:
dao:
List<MissionDTO> queryMissionList(@Param("model") QueryMissionModel obj, @Param("start") Integer start,
@Param("offset") Integer offset);
xml:
<select id="queryMissionList" resultMap="BaseResultMap">
SELECT *
FROM cia_mission
WHERE 1=1
<if test="model.id != null and model.id != '' ">
AND id = #{model.id,jdbcType=VARCHAR}
</if>
<if test="model.title != null and model.title != '' ">
AND title LIKE "%"#{model.title,jdbcType=VARCHAR}"%"
</if>
<if test="model.descri != null and model.descri != '' ">
AND descri = LIKE "%"#{model.descri,jdbcType=VARCHAR}"%"
</if>
<if test="model.beginTime != null" >
AND start_time >= #{model.beginTime,jdbcType=TIMESTAMP}
</if>
<if test="model.endTime != null" >
AND #{model.endTime,jdbcType=TIMESTAMP} > end_time
</if>
<if test="model.createUserId != null and model.createUserId != ''">
AND create_user_id = #{model.createUserId,jdbcType=VARCHAR}
</if>
<if test="model.reviewedUserId != null and model.reviewedUserId != '' ">
AND reviewed_user_id = #{model.reviewedUserId,jdbcType=VARCHAR}
</if>
<if test=" model.missionStatus != null">
AND mission_status = #{model.missionStatus,jdbcType=VARCHAR,typeHandler=org.apache.ibatis.type.EnumTypeHandler}
</if>
ORDER BY create_time DESC
LIMIT #{start}, #{offset}
</select>