It's all about
connecting the dots

MyBatis报错:there is no getter for property named * in class java.lang.String

目录

Bug:

在MyBatis里原先是这么写的,执行后报错:there is no getter for property named agentmechId in class java.lang.String。

<select id="getRolesListByAgentmechId" parameterType="java.lang.String" resultType="java.util.Map">
    select DISTINCT a.ROLE_ID AS ROLEID, C.USER_ID AS USERID  from TL_MANAGE_RIGHT_DATA a
    left join TL_MANAGE_USER_ROLE B ON A.ROLE_ID=B.ROLE_ID
    LEFT JOIN TL_MANAGE_USER c on B.USER_ID = C.USER_DEPID
    where a.ROLE_ID not in(1)
    <if test="agentmechId != '' and agentmechId != null">
        and a.NUM_AGENTMECHID in (${agentmechId})
    </if>
</select>

Fix:

parameterType为String时,用_parameter代替入参名,正确写法:

<select id="getRolesListByAgentmechId" parameterType="java.lang.String" resultType="java.util.Map">
    select DISTINCT a.ROLE_ID AS ROLEID, C.USER_ID AS USERID  from TL_MANAGE_RIGHT_DATA a
    left join TL_MANAGE_USER_ROLE B ON A.ROLE_ID=B.ROLE_ID
    LEFT JOIN TL_MANAGE_USER c on B.USER_ID = C.USER_DEPID
    where a.ROLE_ID not in(1)
    <if test="_parameter != null and _parameter != ''">
        and a.NUM_AGENTMECHID in (${_parameter})
    </if>
</select>

 

赞(0) 打赏
版权声明:非商业用途转载请注明文章链接,商业用途转载请联系邮箱获取授权。
文章名称:《MyBatis报错:there is no getter for property named * in class java.lang.String》
文章链接:https://www.orzzone.com/mybaits-no-getter-property-named-class-java-lang-string.html
商业联系:yakima.public@gmail.com
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏