转载自://http://www.cnblogs.com/anee/p/3324140.html
用mybatis查询时,传入一个字符串传参数,且进行判断时,会报
- There is no getter for property named 'moduleCode' in 'class java.lang.String
错误写法:
- <select id="queryAllParentModule" resultType="jobModule" parameterType="jobModule">
- select modulecode,
- modulename,
- modulevalue,
- linkurl,
- rank,
- parentmodule=isnull(parentmodule,1),
- moduledescription
- from job_module
- <where>
- <choose>
- <when test="moduleCode!=null and moduleCode!=''">modulecode = #{moduleCode}</when>
- <when test="moduleCode==null or moduleCode==''">(parentmodule is null or len(parentmodule)<=0)</when>
- </choose>
- </where>
- lt;/select>
需要修改成:
- <select id="queryModuleByCode" resultType="jobModule" parameterType="string">
- select modulecode,
- modulename,
- modulevalue,
- linkurl,
- rank,
- parentmodule=isnull(parentmodule,1),
- moduledescription
- from job_module
- <where>
- <choose>
- <when test="_parameter!=null and _parameter!=''">modulecode = #{_parameter}</when>
- <when test="_parameter==null or _parameter==''">(parentmodule is null or len(parentmodule)<=0)</when>
- </choose>
- </where>
- lt;/select>
不管你的参数是什么,都要改成"_parameter"
REFERENCES:http://txin0814.iteye.com/blog/1533645
---------------------------------------------------------------------------------------------------------------------------------
copyright:http://www.cnblogs.com/anee/