我正在尝试实现以下 ibatis 插入注释,但不断收到以下错误消息:
org.apache.ibatis.binding.BindingException: Parameter 'person' not found. Available parameters are [arg1, arg0, param1, param2]
这是我到目前为止的代码。我该如何修复它?
@(Insert("INSERT INTO profile (person, school) VALUES (#{person}, #{school})";)
void insertOne(TestTextMessage person, String school)
一些背景:
尝试过这个... @(Insert("INSERT INTO profile (person, school) VALUES (#{arg0}, #{arg1})";)
但得到了 java.lang。现在断言错误。TestTextMessage 是一个包含以下值的类:
@Data
@NoArgs
@EqualsAndHashCode
public class TestTextMessage {
private long id;
private String name;
private int age;
}
目前我这样调用它:
messageMapper.insertOne(new TestTextMessage(person1), SchoolType.EDENGLEN);
如果我将学校类型移至类(class),那么它应该可以工作,但是如何为学校类型分配值?
最佳答案
使用arg0
和arg1
@(Insert("INSERT INTO profile (person, school) VALUES (#{arg0}, #{arg1})")
或
使用@Param
为参数命名。
void insertOne(@Param("person")TestTextMessage person, @Param("school") String school)
关于java - Ibatis绑定(bind)异常错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49996985/