動(dòng)態(tài)參數(shù)拼接的查詢(xún)語(yǔ)句
–傳入?yún)?shù)類(lèi)型為自定義數(shù)據(jù)類(lèi)型
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> |
刪除單條數(shù)據(jù)
–傳入?yún)?shù)類(lèi)型為String與基本數(shù)據(jù)類(lèi)型
1
2
3
|
<delete id= "deleteOne" parameterType= "int" > delete from MESSAGE WHERE ID = #{_parameter} </delete> |
刪除多條數(shù)據(jù)
–傳入?yún)?shù)類(lèi)型為L(zhǎng)ist
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配置文件之動(dòng)態(tài)SQL配置備忘錄,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!
原文鏈接:http://blog.csdn.net/qq_38325620/article/details/72565356