1. Question:
The problem occurs: using MybatisPlus for testing
1. Entity class
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Book {
int bookId;
String bookName;
int bookCounts;
String detail;
2. Test class
/**
* 通过id修改用户信息
*/
@Test
public void testUpdateById(){
Book b=new Book();
b.setBookId(15);
b.setBookName("《Linux私房菜》");
b.setDetail("好好学习指令 这是2.0版本");
b.setBookCounts(100);
int res=bookMapper.updateById(b);
System.out.println(res);
}
Then an error occurred when testing
2. Analyze the problem
Invalid bound statement (not found) Invalid bound statement (not found)
We found that the id we bound was not found, because I used the updateById method and needed to find it through the id.
So, you need to add a mybatisplus annotation @TableId
Check out the official documentation:
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Book {
@TableId
int bookId;
String bookName;
int bookCounts;
String detail;