Difference between isNull, isNotNull and isEmpty, isNotEmpty in ibatis

[html] view plain copy
<span style="font-family: Arial, Verdana, sans-serif; white-space: normal; "><strong>isNull, isNotNull and isEmpty, isNotEmpty difference</strong></span> 
In iBATIS isNull is used to judge whether the parameter is Null, isNotNull is the opposite
isEmpty judges whether the parameter is Null or empty, if one of the conditions is met, it is true
isNotEmpty On the contrary, when the parameter is neither Null nor empty, it is true
after the judgment The corresponding expression operation

is as follows :
  
[html] view plain copy
<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> 

when passed the parameter cusWebForm instead of When passing in cusWebAgent, the generated SQL statement is:
select count(cus_id) from cus_customer_tbl WHERE ( CUS_CUSTOMER_TBL.CUS_WEB_FROM LIKE '%baidu%')

and when the XML code is configured with <isNotNull> (note the difference between them),
[html] view plain copy
<select id="getCustomerRegNum" resultClass="int" parameterClass="QueryCustomerCondition"> 
          select count(cus_id) from cus_customer_tbl  
          <  dynamic prepend="WHERE"> 
            <isNotNull prepend="AND" property="cusWebFrom"> 
                ( CUS_CUSTOMER_TBL.CUS_WEB_FROM LIKE '%$cusWebFrom$%') 
            </isNotNull> 
            <isNotNull prepend="AND" property="cusWebAgent"> 
                ( CUS_CUSTOMER_TBL.CUS_WEB_AGENT LIKE '% $cusWebAgent$%') 
            </isNotNull> 
          </dynamic> 
   </select> 

Similarly, when the parameter cusWebForm is passed instead of cusWebAgent, the generated SQL statement is:
select count(cus_id) from cus_customer_tbl WHERE ( CUS_CUSTOMER_TBL. CUS_WEB_FROM LIKE '%baidu%') AND (CUS_CUSTOMER_TBL.CUS_WEB_AGENT LIKE '%%')

The difference between them can be seen from the Sql statement. . . . .

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326847966&siteId=291194637