查询条件使用到日期的时候报出
实体类里字段都是正确对应的
SQL语句形式类似为:
select tv.*
from account_sel_view tv
where 1=1
<if test="regstartDate!=null and regstartDate!=''">
and startDate >= to_date('#{regstartDate}','yyyy-mm-dd HH24:MI:SS')
</if>
<if test="regendDate!=null and regendDate!=''">
and startDate <= to_date('#{regendDate}','yyyy-mm-dd HH24:MI:SS')
</if>
<if test="allNumLow!=null and allNumLow!=''">
and dealSum >= TO_NUMBER(#{allNumLow})
</if>
<if test="allNumHigh!=null and allNumHigh!=''">
and dealSum <= TO_NUMBER(#{allNumHigh})
</if>
以上问题是因为:
to_date的参数不可加上' '。
正确写法为:
<if test="regstartDate!=null and regstartDate!=''">
and startDate >= to_date(#{regstartDate},'yyyy-mm-dd HH24:MI:SS')
</if>
<if test="regendDate!=null and regendDate!=''">
and startDate <= to_date(#{regendDate},'yyyy-mm-dd HH24:MI:SS')
</if>