我正在使用iBatis 2.3进行一个项目。我想知道是否有可能在同一个标记中进行多个值比较。
示例:
<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条件,但可读性较低,且不完全清楚两个标签之间的联系,它们是同一条件的一部分。
谢谢
发布于 2017-05-09 20:41:11
如果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>https://stackoverflow.com/questions/43844388
复制相似问题