本文由我司收集整编,推荐下载,如有疑问,请与我司联系
Mybatis
进行
id
类型、
String
类型、
map
类型、
ben
类型参数传入
Sql
查询
2017/07/21 0
Mybatis
进行
id
类型、
String
类型、
map
类型、
ben
类型参数传入
Sql
查询查看原文:
ibloger/article/285.html
用习惯了
hibernate
,再换成
Mybatis
总会遇到一些变态问题,正如下面的错误提
示,用
mybatis
查询时,传入一个字符串传参数,且进行判断时,会报
错误
[java]view
plaincopyprint?Thereisnogetterforpropertynamed’moduleCode’in’classjava.lang.StringDa
o
层调用方式
[java]view
plaincopyprint?/**Dao
层查询
*/@OverridepublicList
CityFace
findCityFaceByCondition(StringeqDate){returnsqlSession.selectList(CityFace.class.getNa
me() _Mapper.findCityFaceByCondition ,eqDate);}
常见的错误写法:
XML
映射
Sql
[html]view plaincopyprint? selectid= findCityFaceByCondition parameterType= String
resultType=
CityFace
select*from(selectunitname,to_char(rdate,’yyyy-
MM’)rdate,analysistype,scopefromCITYSCAPEANALYSIS)pivot(sum(scope)foranalysist
ypein(‘ESScope’esscope,’EOScope’eoscope,’GCScope’gcscope,’CScope’cscope))
iftest=‘eqDate!= ‘ whererdate=#{eqDate} /if
/select
需要修改成:
[html]view plaincopyprint? selectid= findCityFaceByCondition parameterType= String
resultType=
CityFace
select*from(selectunitname,to_char(rdate,’yyyy-
MM’)rdate,analysistype,scopefromCITYSCAPEANALYSIS)pivot(sum(scope)foranalysist
ypein(‘ESScope’esscope,’EOScope’eoscope,’GCScope’gcscope,’CScope’cscope))
iftest=‘_parameter!= ‘ whererdate=#{_parameter} /if
/select
不管你的参数是什么,都
要改成
_parameter
,但是
ID
就不用改就行
Java
调用
ID
示例
[java]view