我传入一个map,语句里边判断如果存在map中有startDate、endDate两个参数,则设置条件,但查询时报错,得不到结果,请大家帮忙诊断下,谢谢了。配置语句如下<select id="getLogs" parameterClass="java.util.HashMap" resultClass="LogItem">
<![CDATA[select recNum, roleId, roleName, roleDesc
from (select rownum r, a.OPERLOG_ID logId, a.OPERATOR_NO logOper,
a.OPER_TYPE logType, (select OPER_DESC from OPERTYPE where OPERTYPE_ID = a.OPER_TYPE) logTypeName,
a.OPER_HAPPENTIME logHappenTime, a.OPER_IP logIp, a.OPER_RESULT logResult,
Decode(a.OPER_RESULT,0,'失败',1,'成功','失败') as logResultName,
a.OPER_REMARK logRe,
sum(1)over() as recNum
from oper_log a
<dynamic prepend="WHERE">
<isPropertyAvailable property="startDate">
<isNotNull prepend=" and " property="startDate">
oper_insert_time >= to_date(#startDate# || ' 00:00:00', 'YYYY-MM-DD hh24:mi:ss')
</isNotNull>
</isPropertyAvailable>
<isPropertyAvailable property="endDate">
<isNotNull prepend=" and " property="endDate">
oper_insert_time <= to_date(#endDate# || ' 23:59:59', 'YYYY-MM-DD hh24:mi:ss')
</isNotNull>
</isPropertyAvailable>
</dynamic>
)c
where r <= #indEnd# and r > #indStart#]]>
</select>
<![CDATA[select recNum, roleId, roleName, roleDesc
from (select rownum r, a.OPERLOG_ID logId, a.OPERATOR_NO logOper,
a.OPER_TYPE logType, (select OPER_DESC from OPERTYPE where OPERTYPE_ID = a.OPER_TYPE) logTypeName,
a.OPER_HAPPENTIME logHappenTime, a.OPER_IP logIp, a.OPER_RESULT logResult,
Decode(a.OPER_RESULT,0,'失败',1,'成功','失败') as logResultName,
a.OPER_REMARK logRe,
sum(1)over() as recNum
from oper_log a
<dynamic prepend="WHERE">
<isPropertyAvailable property="startDate">
<isNotNull prepend=" and " property="startDate">
oper_insert_time >= to_date(#startDate# || ' 00:00:00', 'YYYY-MM-DD hh24:mi:ss')
</isNotNull>
</isPropertyAvailable>
<isPropertyAvailable property="endDate">
<isNotNull prepend=" and " property="endDate">
oper_insert_time <= to_date(#endDate# || ' 23:59:59', 'YYYY-MM-DD hh24:mi:ss')
</isNotNull>
</isPropertyAvailable>
</dynamic>
)c
where r <= #indEnd# and r > #indStart#]]>
</select>
解决方案 »
- tomcat内存占用大,响应慢
- IntelliJ 部署web出现问题
- 如何调整点击<input type=file>浏览按钮后文件选择对话框中可选择文件类型?
- 问一个SQL语句有人可以帮我改改吗?谢谢
- js 做树形结构时,怎么样使当点击一个节点时,不是跳转页面,而是执行别的函数呢?
- jasperreport中怎样传入一整条SQL语句
- 一个员工属于:生产一科,1715车间,甲组 怎么设计数据库存放员工的部门
- 急求:如何在Jsp里面加下级目录呀!
- 求助新闻发布和管理系统的jsp源代码?
- hibernate内部如何判断持久化类是否发生改变
- 在使用StringBuffer时,当字符串过长时,出现java.lang.OutOfMemoryError: Java heap space
- 如何用好hibernate+spring+struts2这个框架?
select recNum, roleId, roleName, roleDesc
from (select rownum r, a.OPERLOG_ID logId, a.OPERATOR_NO logOper,
a.OPER_TYPE logType, (select OPER_DESC from OPERTYPE where OPERTYPE_ID = a.OPER_TYPE) logTypeName,
a.OPER_HAPPENTIME logHappenTime, a.OPER_IP logIp, a.OPER_RESULT logResult,
Decode(a.OPER_RESULT,0,'失败',1,'成功','失败') as logResultName,
a.OPER_REMARK logRe,
sum(1)over() as recNum
from oper_log a
<dynamic prepend="WHERE">
<isPropertyAvailable property="startDate">
<isNotNull prepend=" and " property="startDate">
oper_insert_time >= to_date(#startDate# || ' 00:00:00', 'YYYY-MM-DD hh24:mi:ss')
</isNotNull>
</isPropertyAvailable> <isPropertyAvailable property="endDate">
<isNotNull prepend=" and " property="endDate">
oper_insert_time <= to_date(#endDate# || ' 23:59:59', 'YYYY-MM-DD hh24:mi:ss')
</isNotNull>
</isPropertyAvailable> </dynamic>
)c
<![CDATA[where r <= #indEnd# and r > #indStart#]]>
还有sql语句尽量都大写。