动态参数拼接的查询语句
–传入参数类型为自定义数据类型
<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配置备忘录,希望对大家有所帮助
如对本文有疑问, 点击进行留言回复!!
SpringBoot中定制异常页面(404页面配置提高用户体验)
Spring-Boot快速集成netty-socketio(socket服务实现,支持认证)
网友评论