忘记昵称了 2023-01-31 23:29 采纳率: 0%
浏览 39

mybatis报错 Could not set parameters for mapping

求友友帮助: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).

  • 写回答

3条回答 默认 最新

  • wux_labs 2023-02-01 00:09
    关注

    你这个地方的分隔符少了引号。

    img

    修改如下,如果有用,望采纳,谢谢!

     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月31日

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题