mybatis多参数dao层方法和XML文件写法

1.常规写法@param注解

int updatePwdById(@Param("userId")Integer userId, @Param("password")String password);

xml文件

<update id="updatePwdById">
		UPDATE sys_user
		SET password = #{password}
		WHERE user_id = #{userId}
</update>

2.不加注解,xml通过索引获取参数

int updatePwdById(Integer userId, String password);

xml文件

<update id="updatePwdById">
		UPDATE sys_user
		SET password = #{arg1}
		WHERE user_id = #{arg0}
</update>

或者

<update id="updatePwdById">
		UPDATE sys_user
		SET password = #{param2}
		WHERE user_id = #{param1}
</update>
发布了47 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_37460672/article/details/104020643
今日推荐