mybatis if test 使用遇到问题了,望大神指点

柔情小汪汪 2017-03-14 11:24:33
<!-- 实际上报次数 -->
<select id="searchPatientInfo_6" resultType="java.lang.Integer" parameterType="com.ustcsoft.qc.web.checkItemScore.action.form.ReportMsgTabReqForm">
select count(*)
from(
select *
from ${tabNameDB}
where make_date >=#{beginDate} and make_date <#{date6_1} and del_flag='0'
group by pnt_id
<if test="#{date6_2l}<=#{endDatel}">
union all
select *
from ${tabNameDB}
where make_date >=#{date6_1} and make_date <#{date6_2} and del_flag='0'
group by pnt_id
</if>
<if test="#{date6_3l}<=#{endDatel}">
union all
select *
from ${tabNameDB}
where make_date >=#{date6_2} and make_date <#{date6_3} and del_flag='0'
group by pnt_id
</if>
<if test="#{date6_4l}<=#{endDatel}">
union all
select *
from ${tabNameDB}
where make_date >=#{date6_3} and make_date <#{date6_4} and del_flag='0'
group by pnt_id
</if>
<if test="#{date6_5l}<=#{endDatel}">
union all
select *
from ${tabNameDB}
where make_date >=#{date6_4} and make_date <#{date6_5} and del_flag='0'
group by pnt_id
</if>
<if test="#{date6_6l}<=#{endDatel}">
union all
select *
from ${tabNameDB}
where make_date >=#{date6_5} and make_date <#{date6_6} and del_flag='0'
group by pnt_id
</if>

) a
</select>













报错是:### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
### Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
[DEBUG] 11:02:49.596 [http-nio-8080-exec-2] ResponseStatusExceptionResolver - Resolving exception from handler [public com.ustcsoft.apollofw.web.response.bean.JsonDataList<com.ustcsoft.qc.web.checkItemScore.action.form.ReportMsgTabResForm> com.ustcsoft.qc.web.checkItemScore.action.ReportMsgTabAction.getData()]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
### Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
[DEBUG] 11:02:49.596 [http-nio-8080-exec-2] DefaultHandlerExceptionResolver - Resolving exception from handler [public com.ustcsoft.apollofw.web.response.bean.JsonDataList<com.ustcsoft.qc.web.checkItemScore.action.form.ReportMsgTabResForm> com.ustcsoft.qc.web.checkItemScore.action.ReportMsgTabAction.getData()]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
### Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
[WARN ] 11:02:49.597 [http-nio-8080-exec-2] ExceptionResolverComposite - Ajax请求异常:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
### Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap
...全文
619 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_32154601 2017-03-21
  • 打赏
  • 举报
回复
if test 不需要#{},再把大于小于换成<>,还有你返回类型是integer,看看dao接收是否是int类型
pinko323 2017-03-17
  • 打赏
  • 举报
回复
if test 的值能写#{}???????????????? 还有 少用$ 会sql注入
podd 2017-03-16
  • 打赏
  • 举报
回复
Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap 参数问题,传值之前检查下传入的值都是什么,或者配置个log4日志,把执行和sql语句和参数在控制台上打印出来
beqiang 2017-03-16
  • 打赏
  • 举报
回复
resultType和parameterType看反了不好意思。 动态sql的test中不需要用#{}包裹了,会自动从请求参数中获取
beqiang 2017-03-16
  • 打赏
  • 举报
回复
我看到了报错的第一行: ### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.LinkedHashMap and java.util.LinkedHashMap 楼主你的sql配置中parameterType是Integer,只有传入参数为数组和list,parameterType才为其中的元素类型。但如果传入类型是Map的话还是要写成java.util.Map的
菜 头 2017-03-16
  • 打赏
  • 举报
回复
if-test不应该这么写吧,比如<if test="#{date6_2l}<=#{endDatel}">,应该怎样吧: <if test="date6_2l<=endDatel">
快乐的xiao2b 2017-03-15
  • 打赏
  • 举报
回复
检查一下参数对不对 ,是不是有等于 null的尼
柔情小汪汪 2017-03-14
  • 打赏
  • 举报
回复
柔情小汪汪 2017-03-14
  • 打赏
  • 举报
回复
公司网屏蔽了文件的传送,,哎
qq_34954326 2017-03-14
  • 打赏
  • 举报
回复
那就别用if else 你这样发代码 没人看的下去,截图吧

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧