Mybaits--配置文件之动态SQL配置备忘录

动态参数拼接–select语句

–传入参数类型为自定义数据类型

<select id="queryMessageList" parameterType="com.imooc.bean.Message"
        resultMap="MessageResult">
        select ID,COMMAND,DESCRIPTION,CONTENT from MESSAGE where 1=1
        <if test="command !=null &amp;&amp;!&quot;&quot;.equals(command.trim())">
            and COMMAND=#{command}
        </if> <if test="description != null and !&quot;&quot;.equals(description.trim())"> and DESCRIPTION like '%' #{description} '%' </if>
    </select>

删除单条数据–delete语句

–传入参数类型为String或基本数据类型

<delete id="deleteOne" parameterType="int">
        delete from MESSAGE WHERE ID = #{_parameter}
</delete>

删除多条数据–delete拼接语句

–传入参数类型为List

    <delete id="deleteBatch" parameterType="java.util.List">
        delete from MESSAGE WHERE ID in (
        <foreach collection="list" item="item" separator=",">
            #{item}
        </foreach> ) </delete>

你可能感兴趣的:(sql,数据,Class,select)