Search code examples
javamybatisibatis

Ibatis binding exception error message


I am trying to implement the following ibatis insert annotation but keep getting the following error message:

org.apache.ibatis.binding.BindingException: Parameter 'person' not found. Available parameters are [arg1, arg0, param1, param2]

This is my code so far. How do I fix it?

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

Some context:

Tried this... @(Insert("INSERT INTO profile (person, school) VALUES (#{arg0}, #{arg1})";) but getting a java.lang.Assertion error right now. TestTextMessage is a class containing the following values:

@Data
@NoArgs
@EqualsAndHashCode
public class TestTextMessage {
   private long id;
   private String name;
   private int age;
}

and currently I call it like this:

messageMapper.insertOne(new TestTextMessage(person1), SchoolType.EDENGLEN);

if i move school type to the class, then it should work but then how do i assign a value to school type?


Solution

  • Use arg0 and arg1

    @(Insert("INSERT INTO profile (person, school) VALUES (#{arg0}, #{arg1})")
    

    or

    Use @Param to give param a name.

    void insertOne(@Param("person")TestTextMessage person, @Param("school") String school)