要实现你的需求,建议改为直接由SQL语句来实现比较方便,以下以Oracle为例 and ( (CONSIGNED_DATE > #consignmentDate1# and CONSIGNED_DATE < #consignmentDate2# and #consignmentDate1# is not null and #consignmentDate2# is not null) or (CONSIGNED_DATE < #consignmentDate2# and #consignmentDate1# is not null and #consignmentDate2# is null) or (CONSIGNED_DATE > #consignmentDate2# and #consignmentDate1# is null and #consignmentDate2# is not null) )
<isEmpty property="consignmentDate1"><isNotEmpty property="consignmentDate2">CONSIGNED_DATE <![CDATA[ < ]]>#consignmentDate2#</isNotEmpty></isEmpty>
<isNotEmpty property="consignmentDate1"><isEmpty property="consignmentDate2">CONSIGNED_DATE <![CDATA[ > ]]>#consignmentDate1#</isEmpty></isNotEmpty>
<isNotEmpty property="consignmentDate1"><isNotEmpty property="consignmentDate2">CONSIGNED_DATE between #consignmentDate1# and #consignmentDate1#</isNotEmpty></isNotEmpty>
<select id="qryIllegallogHisCunt" parameterClass="smsLog" resultClass="java.lang.Integer">
select count(*) from t_hist_log_uncommon
<dynamic prepend="where">
<isNotEmpty prepend="and" property="beginDate">
<![CDATA[convert(char(8),occur_time,112)>=#beginDate#]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="endDate">
<![CDATA[convert(char(8),occur_time,112) <= #endDate#]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="teleCompany">
tele_company_type=#teleCompany#
</isNotEmpty>
<isNotEmpty prepend="and" property="serialNo">
serial_no=#serialNo#
</isNotEmpty>
</dynamic>
</select>
实现按日期查询!与你功能不一样在于输入单个时我是按>=而你是按>,可以按你自己的要求改进!
然后从LOG中看实际的SQL语句
(CONSIGNED_DATE > #consignmentDate1#
and CONSIGNED_DATE < #consignmentDate2#
and #consignmentDate1# is not null
and #consignmentDate2# is not null)
or
(CONSIGNED_DATE < #consignmentDate2#
and #consignmentDate1# is not null
and #consignmentDate2# is null)
or
(CONSIGNED_DATE > #consignmentDate2#
and #consignmentDate1# is null
and #consignmentDate2# is not null)
)