目录
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>