2017-05-08 4246 views
1

我正在與一個項目iBatis 2.3。我想知道是否可以在同一個標​​籤中進行多重值比較。iBatis IsEqual比較一個標籤中的多個值

例如:

<isEqual property="test" compareValue="A OR B"> 
....mySQL... 
</isEqual> 

<isEqual property="test" compareValue="A AND B"> 
....mySQL... 
</isEqual> 

我目前使用的OR條件語句列表:

<isEqual property="test" compareValue="A"> 
    ....mySQL... 
</isEqual> 
<isEqual property="test" compareValue="B"> 
    ....mySQL... 
</isEqual> 

和嵌套的標籤獲得AND條件, 但可讀性低,不十分清楚兩個標籤之間的聯繫是否屬於同一個條件。

謝謝

回答

0

這將是可能的,如果A和B是在列表中,我想他們是不是。所以,如果你通過A和B作爲一個列表參數,你可以做下一個:

<iterate prepend=」AND」 open=」(」 close=」)」 conjunction=」OR」> 
    test=#[]# 
</iterate> 

如果沒有,您需要使用不同的標籤,像下一個:

<dynamic prepend="where"> 
< isEqual prepend="and" property="test" compareValue="A"> 
    ... 
</isEqual> 
< isEqual prepend="and" property="test" compareValue="B"> 
... 
</isEqual> 
</select> 
+0

可惜不是我所需要的。用我可以製作SQL條件。我試圖在ibastis標籤中添加條件。謝謝你的答案eatherway – axelzaro

+1

所以不可能你想要的。 – Pau