1. 程式人生 > >專案中ibatis的isNotNull和isNotEmpty區別

專案中ibatis的isNotNull和isNotEmpty區別

一個困擾了很久的問題原來是因為思想固化了,一直跟著別人的思路走。

先上程式碼:

<isNotEmpty property="payNo">
and tbd.order_id = #payNo#
</isNotEmpty>

<!-- <isNotNull property="payNo">
and tbd.order_id = #payNo#
</isNotNull> -->

isNotNull:當引數不為null時。

isNotEmpty:當引數既不為空也不為Null。做如下操作。

場景:

<tr>
<td><div align="right">入賬時間:</div></td>
<td colspan="1">
<input class="Wdate" type="text" id="startTime" name="startTime" onClick="WdatePicker({lang:'zh_CN',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'endTime\',{M:-3})}',maxDate:'#F{$dp.$D(\'endTime\')}'})" value="${stValue!''}">
至 <input class="Wdate" type="text" id="endTime"name="endTime" onClick="WdatePicker({lang:'zh_CN',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'startTime\')}',maxDate:'%y-%M-%d %H:%m:%s'})" value="${eValue!''}">
</td>
<td><div align="right">交易流水號:</div></td>
<td><input type="text" id="payNo" name="payNo" class="base-input"></td>
<td colspan="1"></td>
</tr>

同樣的引數,一個可以根據OrderId查出來相對應的資料一個則查出來所有資料。

從SQL中我們可以看出當OrderId有值時,編譯器可以取得到 Debug模式可以查出資料,但是當它沒值的時候就出問題了。?引數一一對應。

SQL1:select fundTrace,balanceDate,pay,revenue,payerAccount,payeeAccount,payeeFee,payerFee,payNo,dealCode from (
SELECT ROWNUM rn,fundTrace,balanceDate,pay,revenue,payerAccount,payeeAccount,payeeFee,payerFee,payNo,dealCode FROM ( 
SELECT      

tbd.deal_type fundTrace,     

tbd.create_date balanceDate,     

decode(tbd.payer_full_mem_acctcode,'2243010220110000003671201',tbd.amount) pay,     decode(tbd.payee_full_mem_acctcode,'2243010220110000003671201',tbd.amount) revenue,   
tbd.payer_full_mem_acctcode payerAccount,    

tbd.payee_full_mem_acctcode payeeAccount,     

tbd.payee_fee payeeFee, 
tbd.payer_fee payerFee, 

tbd.order_id payNo,     

tbd.deal_code dealCode    FROM      

t_balance_deal tbd    WHERE     tbd.amount > 0                     

AND (tbd.payer_full_mem_acctcode = '2243010220110000003671201' OR tbd.payee_full_mem_acctcode = '2243010220110000003671201')   
 and tbd.order_id ='1061509251514022491'            order by         bdeal_id desc            ) t)   
 

http://blog.csdn.net/Singit

SQL2:select fundTrace,balanceDate,pay,revenue,payerAccount,payeeAccount,payeeFee,payerFee,payNo,dealCode from (  
SELECT ROWNUM rn,fundTrace,balanceDate,pay,revenue,payerAccount,payeeAccount,payeeFee,payerFee,payNo,dealCode FROM ( 
SELECT      tbd.deal_type fundTrace,     tbd.create_date balanceDate,     decode(tbd.payer_full_mem_acctcode,'2243010220110000003671201',tbd.amount) pay,  
decode(tbd.payee_full_mem_acctcode,'2243010220110000003671201',tbd.amount) revenue,     tbd.payer_full_mem_acctcode payerAccount,    
tbd.payee_full_mem_acctcode payeeAccount,     tbd.payee_fee payeeFee,     tbd.payer_fee payerFee,          tbd.order_id payNo,    
tbd.deal_code dealCode    FROM      t_balance_deal tbd    WHERE     tbd.amount > 0              
AND (tbd.payer_full_mem_acctcode = '2243010220110000003671201' OR tbd.payee_full_mem_acctcode = '2243010220110000003671201')                     
and tbd.create_date between ? and ?                                                   
and tbd.order_id = ?            order by         bdeal_id desc            ) t) where  rn between ? and ? 

引數一一補上之後發現依然會報錯。

N遍斷點Debug之後發現原來是isNotEmpty的問題。