Mybatis--<![CDATA[ sql 语句 ]]> 不用解析

来源:互联网 发布:省委宣传部 知乎 编辑:程序博客网 时间:2024/05/16 23:55

在mapper文件中写sql语句时,遇到特殊字符时,如:< 等,建议使用<![CDATA[ sql 语句 ]]>标记,将sql语句包裹住,不被解析器解析


<select id="selectUserPaging" resultMap="BaseResultMap" parameterType="map">
        select
        <include refid="Base_Column_List"/>
        from DYRKB_USER
        where 1=1
        <if test="hashMapQuery.privilege != null" >
            and PRIVILEGE = #{hashMapQuery.privilege}
        </if>
        <if test="hashMapQuery.userName != null">
            and USER_NAME like #{hashMapQuery.userName}
        </if>
        <if test="hashMapQuery.email != null">
            and EMAIL like #{hashMapQuery.email}
        </if>
        <if test="hashMapQuery.accountState != null">
            <if test="hashMapQuery.accountState != '16'">
                and ACCOUNT_STATE = #{hashMapQuery.accountState}
            </if>
            <if test="hashMapQuery.accountState == '16'">
                <![CDATA[
                and ACCOUNT_EXPIRE_DATE < now()
               ]]>
            </if>
        </if>
        order by USER_NAME
        limit #{hashMapQuery.pageSize} offset #{hashMapQuery.from}
  </select>

0 0
原创粉丝点击