Mybatis笔记四:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'
2017-03-15 17:22
746 查看
错误异常:nestedexceptionisorg.apache.ibatis.reflection.ReflectionException:Thereisnogetterforpropertynamed'id'in'classjava.lang.String'
映射器类(Mapperinterface)
Xml映射文件配置(部分)
这是MybatisXml映射文件配置,当我执行这个映射select语句时报错:nestedexceptionisorg.apache.ibatis.reflection.ReflectionException:Thereisnogetterforpropertynamed'id'in'classjava.lang.String'
解决办法有两种:
1.去掉sql语句的if标签限制
映射器类(Mapperinterface)
publicinterfaceNarCodeService{ publicNarCodegetNarCode(Stringid); }
Xml映射文件配置(部分)
<selectid="getNarCode"parameterType="java.lang.String" resultType="narCode"> select <includerefid="Base_Column_List"></include> fromnar_code <where> <iftest="id!=null"> id=#{id,jdbcType=VARCHAR} </if> </where> </select>
这是MybatisXml映射文件配置,当我执行这个映射select语句时报错:nestedexceptionisorg.apache.ibatis.reflection.ReflectionException:Thereisnogetterforpropertynamed'id'in'classjava.lang.String'
解决办法有两种:
1.去掉sql语句的if标签限制
<iftest="id!=null"> id=#{id,jdbcType=VARCHAR} </if> 改为: id=#{id,jdbcType=VARCHAR} 原因:我自己猜测加上if标签时,id属性没有包含在数据类型为Stringid对象中。 如果去掉if标签时直接使用这个数据类型为Stringid对象 2.将parameterType="java.lang.String"参数改为传一个自定义实体对象或者HashMap来封装这个id参数 原因:可以在自定义实体对象或者HashMap中找到这个id属性
相关文章推荐
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_lableId_0' in 'class com.cd.entity.Page'
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.
- MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException:
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.Persiste
- Spring错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.B
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'cla
- mybatis报错:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exception
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'funcSetId' in 'class java.lang.Integer'
- nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for propert
- nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for propert
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingExce
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorEx
- MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException
- Spring错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Bi
- Spring+MyBatis 错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.b
- Spring错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Bi
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String'