Faster, Higher, Stronger
更快,更高,更强

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

评论 抢沙发

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

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

支付宝扫一扫打赏

微信扫一扫打赏