Reputation: 13206
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?
Upvotes: 3
Views: 4002
Reputation: 20956
Compile with -parameters
option for storing formal parameter names to bytecode which was added in Java 8 to javac (source)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>${java.release}</release>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
Upvotes: 0
Reputation: 4681
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)
Upvotes: 5