public List findInactiveMainAcctByTypeAndAppCode(String type, String inactiveDays, boolean onlyTheDay,String[] appCodes) {
Map condition = DataBaseUtil.getHashMap();
condition.put("type", Integer.parseInt(type));
condition.put("inactiveDays", Integer.parseInt(inactiveDays));
condition.put("onlyTheDay", onlyTheDay);
condition.put("appCodes",appCodes);
return getSqlMapClientTemplate().queryForList("UapMainAcct.findInactiveMainAcctByType", condition);
}
<select id="findInactiveMainAcctByType" resultMap="uapMainAcctResult">
select * from uap_main_acct t where
t.lock_status = 0
<include refid="defaultProvinceCodeCondition"/>
and
((t.last_login_time is not null
<dynamic prepend="">
<isNotEmpty prepend="AND" property="appCodes">
1!=1
isNotEmpty>
dynamic>
select>
<dynamic prepend="">
<isNotEmpty prepend="AND" property="appCodes">
1!=1
isNotEmpty>
dynamic>
这部分判断进不去,无效;找不到原因
试过 List也不可以
可以正常判断条件
<select id="queryTable" parameterClass="ParameterClass" resultMap="ResultMap">
select * from table where 1 =1
<isNotEmpty property="fromId" prepend="and">
id <![CDATA[>=]]> #fromId#
</isNotEmpty>
<isNotEmpty property="toId" prepend="and">
id <![CDATA[<=]]> #toId#
</isNotEmpty>
order by id
</select>
【仅供参考】
appCodes传过来的值是什么?如果传过来的数组大小为0,也是不会进来的。
1、用
<where> </where >
来包裹这些条件
2、你的字段要实际用到isNotEmpty里面去;
改成这样试试,isNotEmpty 可以单独使用的
<select id="findInactiveMainAcctByType" resultMap="uapMainAcctResult">
select * from uap_main_acct t where
t.lock_status = 0
<include refid="defaultProvinceCodeCondition"/>
and t.last_login_time is not null
<![CDATA[
and t.acct_type=#type#
and (t.GRACE_PERIOD is null or t.GRACE_PERIOD <= 0 )
and not exists(select 1
from uap_main_acct_redlist l
where t.main_acct_id = l.main_acct_id)
]]>
<isNotEmpty prepend="AND" property="appCodes">
1!=1
</isNotEmpty>
</select>
```java
<select id="getCityListByProvinceId"parameterClass="simpleMap"resultClass="dictModel">
<![CDATA[
select xiddictCode, xname dictName from city
]]>
<dynamic prepend= "where ">
<isNotEmptyprepend="and" property="xflag">
<![CDATA[
xflag=$xflag$
]]>
</isNotEmpty>
<isNotEmpty prepend="and"property="xprovinceId">
<![CDATA[
xprovince_id= #xprovinceId#
]]>
</isNotEmpty>
</dynamic>
</select>
```
这样试试呢