求友友帮助:MyBatis中报错Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_item_1', mode=IN, javaType=class java.lang.String, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
代码
// dao层
List<TsBfMenuInfo> selectMenusByCode(@Param("array") List<String> array);
//xml文件
SELECT t3.*, ischild
FROM ( SELECT t1.*, IF (FIND_IN_SET(t1.MENU_CODE_P, @pids) > 0, @pids := CONCAT(@pids, ',', t1.MENU_CODE),'0') ischild
FROM (SELECT t.* FROM t_s_bf_menu_info t ORDER BY t.ORDER_NO ) t1,
(SELECT @pids :=
<foreach collection="array" index="index" item="item" open="'" separator="," close="'">
#{item,jdbcType=VARCHAR}
</foreach>
) t2
) t3
WHERE ischild != '0'
<if test="array != null ">
<foreach collection="array" index="index" item="item" open=" " separator="or" close=" ">
menu_code = #{item,jdbcType=VARCHAR}
</foreach>
</if>
order by t3.order_no
运行结果及详细报错内容
Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_item_1', mode=IN, javaType=class java.lang.String, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).