1. 程式人生 > >mybatis動態排序

mybatis動態排序

   <select id="getLinkTypeListByCondition" parameterType="java.util.Map"  resultMap="linkType">
        SELECT * FROM OD_LINK_TYPE
        <where>
            LINK_URI != BASE_TYPE_URI
            <if test="linkUri != null">
               AND LINK_URI LIKE '%${linkUri}%'
            </if
>
<if test="linkLabel != null"> AND LINK_LABEL LIKE '%${linkLabel}%' </if> <if test="baseTypeUri != null"> AND BASE_TYPE_URI=#{baseTypeUri} </if> </where> <if test="orderfield != null"
> ORDER BY <choose> <when test="orderfield == 'linkUri'"> LINK_URI ${orderdir} </when> <when test="orderfield == 'linkLabel'"> LINK_LABEL ${orderdir} </when
>
<otherwise> BASE_TYPE_URI ${orderdir} </otherwise> </choose> </if>
</select>