Mybatis中发生Parameter xx not found. Available parameters are [arg1, arg0, param1, param] 错误可能的情况

Posted 咸鸭蛋白

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mybatis中发生Parameter xx not found. Available parameters are [arg1, arg0, param1, param] 错误可能的情况相关的知识,希望对你有一定的参考价值。

目录

Parameter xx not found. Available parameters are [arg1, arg0, param1, param] 的一种原因

解决方法:

引申:



Parameter xx not found. Available parameters are [arg1, arg0, param1, param] 的可能情况

当我们向中间表(s_o)中插入一条属性:

 

 我的接口方法中定义的参数为上图两个,其中nid为students中的idi为objects中的id

那么此时我们应该如何编写sql语句呢?

如果你这么书写,是错误的,会报   Parameter  nid  not found. Available parameters are [arg1, arg0, param1, param2]  错误。

因为我们此时传入的参数类型为Integer类型,而Integer类中并没有 nid 与 i 这个属性,所以编辑器找不到nid这个属性,就会报错了。

解决方法:

 将 nid 替换为 arg0 arg1

此时就不会报错了。

引申:

当你的参数类型为实体类型时,可以使用  #实体属性名 。

当你的参数类型为基本类型时,如(Integer,String ,Boolean 等),使用 #arg0,#arg1……

当你的方法拥有多种参数时,parameterType属性也可以不写(其实基本上都可以不写)

如果本文有帮助,可以点个赞支持以下喽

mybatis插入出现org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty 'xx

确定有setter方法,问题其实是xml文件中,insert的主键的列名写错了,如下,一开始写成ComId

<insert id="insertCom" parameterType="Comment" useGeneratedKeys="true" keyProperty="comId">

以上是关于Mybatis中发生Parameter xx not found. Available parameters are [arg1, arg0, param1, param] 错误可能的情况的主要内容,如果未能解决你的问题,请参考以下文章

mybatis插入出现org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty 'xx

关于mybtis 使用过程中发生There is no getter for property named 'id' in class 'java.lang.String

Mybatis 报错 There is no getter for property named '***' in 'class java.lang.String'(示

MyBatis的两个内置函数

mybatis随笔五之Executor

Mybatis中parameterType和parameterMap的区别