mybatis中传入String类型参数异常
在使用mybatis时,写了一条sql语句,只有一个String类型的参数, 示例代码
<select id="getApplyNum" parameterType="java.lang.String" resultType="java.util.Map"> SELECT t.activity_id AS "activityId", COUNT(1) AS "count" FROM t_user t WHERE t.activity_id IN (${ids}) GROUP BY t.activity_id </select>
Mybatis查询sql传入一个字符串传参数,报There is no getter for property named 'ids' in 'class java.lang.String'。
后来改成如下写法,无论参数名是啥,都要改成"_parameter"。问题解决。
<select id="getApplyNum" parameterType="java.lang.String" resultType="java.util.Map"> SELECT t.activity_id AS "activityId", COUNT(1) AS "count" FROM t_user t WHERE t.activity_id IN (${_parameter}) GROUP BY t.activity_id </select>