// dao层
List selectMenusByCode(@Param("array") List 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).
你这个地方的分隔符少了引号。
修改如下,如果有用,望采纳,谢谢!
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
同意1楼看法
不知道你这个问题是否已经解决, 如果还没有解决的话: