< select id="getUser" parameterType="int" resultType="User">
SELECT * FROM users
WHERE id = #{id}
< if test="username != null">
AND username = #{username}
< /if>
< /select>
<select id="getUser" parameterType="int" resultType="User">
SELECT * FROM users
<where>
<choose>
<when test="id != null">
AND id = #{id}
<when>
<when test="username != null">
AND username = #{username}
<when>
<otherwise>
AND status = 'ACTIVE'
<otherwise>
<choose>
<where>
<select>
<update id="updateUser" parameterType="User">
UPDATE users
<trim prefix="SET" suffixOverrides=",">
<if test="username != null">
username = #{username},
<if>
<if test="password != null">
password = #{password},
<if>
<trim>
WHERE id = #{id}
<update>
<select id="getUsersByIdList" parameterType="List" resultType="User">
SELECT * FROM users
WHERE id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
<foreach>
<select>
<update id="updateUser" parameterType="User">
UPDATE users
<set>
<if test="username != null">
username = #{username},
<if>
<if test="password != null">
password = #{password},
<if>
<set>
WHERE id = #{id}
<update>
<elect id="getUser" parameterType="int" resultType="User">
SELECT * FROM users
WHERE id = #{id}
<if test="username != null">
AND username = #{username}
<if>
<select>
<select id="getUser" parameterType="int" resultType="User">
SELECT * FROM users
<where>
<choose>
<when test="id != null">
AND id = #{id}
<when>
<when test="username != null">
AND username = #{username}
<when>
<otherwise>
AND status = 'ACTIVE'
<otherwise>
<choose>
<where>
<select>