背景
执行 mybatis代码的时候遇到以下异常,接口的定义只有一个String类型层参数。但是在XMl文件中加上了语句就会抛出异常。
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'name' in 'class java.lang.String'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:76)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:421)
at com.sun.proxy.$Proxy35.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:206)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy40.queryCheckerName(Unknown Source)
List<Map<String, Object>> queryCheckerName(String name);
修改前:
<select id="queryCheckerName" resultType="map" parameterType="string">
select name from user where 1=1
<if test="name != null">
and name = #{name}
</if>
</select>
修改后:
<select id="queryCheckerName" resultType="map" parameterType="string">
select name from user where 1=1
<if test="_parameter!= null">
and name = #{name}
</if>
</select>