`

ibatis 中isNull, isNotNull与isEmpty, isNotEmpty区别

 
阅读更多

在iBATIS中isNull用于判断参数是否为Null,isNotNull相反

isEmpty判断参数是否为Null或者空,满足其中一个条件则其true

isNotEmpty相反,当参数既不为Null也不为空是其为true

 判断之后做相对应的表达式操作:

例如:

 

 <typeAlias alias="RiskDetail" type="com.taobao.riskm.domain.RiskDetail" />  
<update id="updateByCatalogCode" parameterClass="RiskDetail">
	update riskm_detail
	set
	<dynamic>
		<isNotNull property="level">
			`level`=#level#,
		</isNotNull>
		<isNotNull property="explainText">
			`explaintext`=#explainText#,
		</isNotNull>	
		<isNotNull property="rectification">
			`rectification`=#rectification#,
		</isNotNull>
		<isNotNull property="answering">
			`answering`=#answering#,
		</isNotNull>	
		<isNotNull property="reservedString">
			`reservedstring`=#reservedString#,
		</isNotNull>	
		<isNotNull property="operator">
			`operator`=#operator#,
		</isNotNull>			
	</dynamic>
	    `modifytime`=now()
		where `catalogcode`=#catalogCode#;
  </update>
 

 又如:

 

<select id="getCustomerRegNum" resultClass="int" parameterClass="QueryCustomerCondition">  
          select count(cus_id) from cus_customer_tbl   
          <dynamic prepend="WHERE">  
            <isNotEmpty prepend="AND" property="cusWebFrom">  
                ( CUS_CUSTOMER_TBL.CUS_WEB_FROM LIKE '%$cusWebFrom$%')  
            </isNotEmpty>  
            <isNotEmpty prepend="AND" property="cusWebAgent">  
                ( CUS_CUSTOMER_TBL.CUS_WEB_AGENT LIKE '%$cusWebAgent$%')  
            </isNotEmpty>  
          </dynamic>  
   </select>  
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics