ibatis 常用标签
prepend:自动在前面加上;自动新手;自动预;自动前置
property:属性
compareValue:指定的常数,值
1 //判断不相等: 2 3 <isNotEqual prepend=" and " property="name" compareValue="intnumber"> 4 5 ===条件=== 6 7 </isNotEqual> 8 9 10 11 //判断相等: 12 13 <isEqual prepend="and" property="name" compareValue="value"> 14 15 ===条件=== 16 17 < /isEqual> 18 19 或 20 21 <isEqual prepend="and" property="name" compareProperty="value"> 22 23 ===条件=== 24 25 < /isEqual> 26 27 //判断是否为空或null: 28 29 <isEmpty prepend="and" property="name"> 30 31 ===条件=== 32 33 </isEmpty> 34 35 <isNull prepend="and" property="name"> 36 37 ===条件=== 38 39 </isNull> 40 41 //判断不为空或不为null: 42 43 44 <isNotEmpty prepend="and" property="name"> 45 46 47 ===条件=== 48 49 50 </isNotEmpty> 51 52 53 <isNotNull prepend="and" property="name"> 54 55 56 ===条件=== 57 58 59 </isNotNull>
注意:
在iBATIS中
isEmpty判断参数是否为Null或者空,满足其中一个条件则其true
isNotEmpty相反,当参数既不为Null也不为空是其为true
而:isNull、isNotNull,只判断是否为null
判断之后做相对应的表达式操作
灵活运用:
1 select * from gr_xx where 1=1 2 3 <isNotNull prepend="and" property="name"> 4 5 bzhm=#name# 6 7 </isNotNull> 8 9 10 update gr_xx 11 12 <isNotNull prepend="set" property="xm"> 13 14 xm=#xm# 15 16 </isNotNull> 17 18 <isNotNull prepend="," property="bzhm"> 19 20 bzhm=#bzhm# 21 22 </isNotNull>
热心技术,并兼吃喝,偶谈风月,不言国事.