int updateByPrimaryKeySelective(Admin record); <update id="updateByPrimaryKeySelective" parameterType="com.example.pojo.Admin" > update admin <set > <if test="username != null" > username = #{username,jdbcType=VARCHAR}, </if> <if test="password != null" > password = #{password,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update>转换为Mybatis注解形式的代码
时间: 2024-03-31 07:38:16 浏览: 316
MyBatis-03动态SQL-01.<if>元素的使用
@Update("update admin " +
"<set>" +
"<if test='username != null'>" +
"username = #{username,jdbcType=VARCHAR}," +
"</if>" +
"<if test='password != null'>" +
"password = #{password,jdbcType=VARCHAR}," +
"</if>" +
"</set>" +
"where id = #{id,jdbcType=INTEGER}")
int updateByPrimaryKeySelective(Admin record);
阅读全文