<iterate property="states" open="(" close=")" conjunction="OR"> <isNotEqual compareValue="1" property="states[]"> STATE=#states[]# </isNotEqual> <isEqual compareValue="1" property="states[]"> STATE not in('0','-1') </isEqual> </iterate>
取循环中的值property与给定值compareValue 作比较 动态拼劲sql,
此例中states为String[],若states为List<?> 可用states[].xxx取值。
iterate标签还有个compareProperty属性,猜测为与某字段对比(未测试)。
另一个应用:
<isNotEmpty prepend=" AND " property="operators"> OPERATORS_CODE in <iterate property="operators" open="(" close=")" conjunction=","> #operators[]# </iterate> </isNotEmpty>