動態參數拼接的查詢語句
–傳入參數類型為自定義數據類型
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