Mybatis-There is no getter for property named 'XXX' in 'class java.lang.String'

<select id="queryLocationIdByMediaName" parameterType="java.lang.String" resultType="cn.com.minbolg.pts.model.TblLocation">
    select * from tbl_location
    <where>
       <if test="mediaAccountName != null">
          mediaAccountName = #{mediaAccountName}
       </if>
    </where>	
    order by update_time asc
</select>



在测试时报错:
There is no getter for property named 'mediaAccountName' in 'class java.lang.String'

问题分析:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.mediaAccountName值,引起报错。
解决方法:  参数前添加@Param(value="mediaAccountName")


public List<TblLocation> queryLocationIdByMediaName(@Param(value="mediaAccountName") String mediaAccountName);

猜你喜欢

转载自yudey.iteye.com/blog/1882431