目录
引入Mybatis-Plus依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
</dependency>
@TableName
指定实体类和数据库表的映射关系。当实体类的类名在转成小写后和数据库表名相同时,可以不指定该注解。
当实体类的类名在转成小写后和数据库表名相同时

类名:User

数据库表名:user
实体类的类名在转成小写后和数据库表名相同时,可以不使用该注解
当实体类的类名在转成小写后和数据库表名不相同时

实体类名:Student

数据库表名:t_table
实体类的类名在转成小写后和数据库表名不相同时,要使用该注解

@Tableld
用于指定实体类的某个属性为对应的主键
例如数据库表的字段名为id

实体类的是use_id;

使用@TableId注解

当实体类里的自增字段与数据库表的主键字段不相同时,使用@TableId注解可以指定实体类的某个属性为对应的主键
当实体类里的自增字段与数据库表的主键字段相同时,就不用使用该注解
如果数据库中没有定义主键自增的时候
可以这样写

当实体类里的自增字段与数据库表的主键字段相同时,但没有表示自增可以这样写

@TableField
当数据库字段名与实体类成员不一致



成员变量名以is开头,且是布尔值
在处理成员变量名以is开头,且是布尔值的时候,它会把is去掉,将剩下的作为字段名
所以要用到@TableField注解来指定该变量名
成员变量名与数据库关键字冲突的时候

先加双引号再加单引号
成员变量不是数据库字段
当实体类定义了一个成员变量,但是数据库表没有设置该字段
