前置条件
创建表
CREATE TABLE `test_table` (
`id` int(9) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(10) CHARACTER SET latin1 DEFAULT NULL COMMENT '姓名',
`sex` tinyint(1) DEFAULT NULL COMMENT '性别',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
实体类
/**
* 缺少package
*/
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("test_table")
public class TestTable {
private Integer id;
private String name;
private Byte sex;
public TestTable() {
}
public TestTable(Integer id, String name, Byte sex) {
this.id = id;
this.name = name;
this.sex = sex;
}
}
测试类