动态参数拼接的查询语句
–传入参数类型为自定义数据类型
1
2
3
4
5
6
7
8
9
10
|
<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与基本数据类型
1
2
3
|
<delete id= "deleteOne" parameterType= "int" > delete from MESSAGE WHERE ID = #{_parameter} </delete> |
删除多条数据
–传入参数类型为List
1
2
3
4
5
6
7
|
<delete id= "deleteBatch" parameterType= "java.util.List" > delete from MESSAGE WHERE ID in ( <foreach collection= "list" item= "item" separator= "," > #{item} </foreach> ) </delete> |
以上所述是小编给大家介绍的Mybaits配置文件之动态SQL配置备忘录,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
原文链接:http://blog.csdn.net/qq_38325620/article/details/72565356