ibatis如何判断是否存在where
我想在1条查询后面加上xx=11但是这个查询是动态sql,可能会有where条件,可能没有
如果没有我就需要写成 where xx=11,有的话我就不需要
请问下如何判断有where就不再加where了
--------------------编程问答--------------------
<statement id="dynamicGetAccountList" resultMap="account-result" >--------------------编程问答-------------------- 不是有<dynamic><isNotNull 节点吗 --------------------编程问答-------------------- 感觉sql要是没有嵌套的话indexof就可以,要是有的话还没想好... --------------------编程问答-------------------- isNotNull不是自动判断吗? --------------------编程问答-------------------- where 1=1 后面直接加查询条件,这样就不存在要不要where的问题了
select * from ACCOUNT
<dynamic prepend="WHERE">
<isNotNull prepend="AND" property="firstName">
ACC_FIRST_NAME = #firstName#
</isNotNull>
<isNotNull prepend="AND" property="lastName">
ACC_LAST_NAME = #lastName#
</isNotNull>
<isNotNull prepend="AND" property="emailAddress">
ACC_EMAIL like #emailAddress#
</isNotNull>
<isGreaterThan prepend="AND" property="id" compareValue="0">
ACC_ID = #id#
</isGreaterThan>
</dynamic>
order by ACC_LAST_NAME
</statement>
补充:Java , Java EE