Ibatis 绑定异常错误提示

met*_*lah 2 java ibatis mybatis

我正在尝试实现以下 ibatis 插入注释,但不断收到以下错误消息:

org.apache.ibatis.binding.BindingException:未找到参数“person”。可用参数有 [arg1, arg0, param1, param2]

到目前为止,这是我的代码。我如何解决它?

@(Insert("INSERT INTO profile (person, school) VALUES (#{person}, #{school})";)
void insertOne(TestTextMessage person, String school)
Run Code Online (Sandbox Code Playgroud)

一些背景:

试过这个...@(Insert("INSERT INTO profile (person, school) VALUES (#{arg0}, #{arg1})";)但现在得到一个 java.lang.Assertion 错误。TestTextMessage 是一个包含以下值的类:

@Data
@NoArgs
@EqualsAndHashCode
public class TestTextMessage {
   private long id;
   private String name;
   private int age;
}
Run Code Online (Sandbox Code Playgroud)

目前我这样称呼它:

messageMapper.insertOne(new TestTextMessage(person1), SchoolType.EDENGLEN);
Run Code Online (Sandbox Code Playgroud)

如果我将学校类型移到班级,那么它应该可以工作,但是我如何为学校类型赋值?

Dea*_* Xu 5

使用arg0arg1

@(Insert("INSERT INTO profile (person, school) VALUES (#{arg0}, #{arg1})")
Run Code Online (Sandbox Code Playgroud)

或者

用于@Param为参数命名。

void insertOne(@Param("person")TestTextMessage person, @Param("school") String school)
Run Code Online (Sandbox Code Playgroud)