`

mybatis的xml中传递参数为基础类型的解决方案

 
阅读更多

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'shopcode' in 'class java.lang.String'

 

使用mybatis拼接动态sql语句的时候产生的异常,异常原因是接口中提供的方法,参数不是封装的对象,而是基础类型,比如String ,int等,

在这种情况下为了避免错误,需要在实体映射文件中把对应的查询参数名改为value,demo如下:

 

List<YtPartershop> get4ProductsByShopcode(String shopcode);

 

 

<select id="getModel"  resultMap="PartershopResultMap" parameterType="java.lang.String">

      select s.*,c.shopcontent,t.templateurl from shop s 

<if test="null != value and ''!= value"> -----把shopcode替换为value

      where s.shopcode=#{value}-----把#{shopcode}替换为#{value}

</if>

</select>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics