动态参数拼接的查询语句
–传入参数类型为自定义数据类型
<select id="queryMessageList" parameterType="com.imooc.bean.Message" resultMap="MessageResult"> select ID,COMMAND,DESCRIPTION,CONTENT from MESSAGE where 1=1 <if test="command !=null &&!"".equals(command.trim())"> and COMMAND=#{command} </if> <if test="description != null and !"".equals(description.trim())"> and DESCRIPTION like '%' #{description} '%' </if> </select>
删除单条数据
–传入参数类型为String与基本数据类型
<delete id="deleteOne" parameterType="int"> delete from MESSAGE WHERE ID = #{_parameter}</delete>
删除多条数据
–传入参数类型为List
<delete id="deleteBatch" parameterType="java.util.List"> delete from MESSAGE WHERE ID in ( <foreach collection="list" item="item" separator=","> #{item} </foreach> ) </delete>
以上所述是小编给大家介绍的Mybaits配置文件之动态SQL配置备忘录,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
新闻热点
疑难解答
图片精选