Mybatis-Plus常用注解

1.如果实体类的名称和数据库表的名称不一样,可以使用@TableName("t_user"),括号中的内容对应数据库表

2.指定主键名称,用@TableId

3.数据库字段和实体字段不一样,可以用@TableField("name") 来表示,括号中的内容对应数据库表字段名

4.某个字段知出现在实体类中,不在数据库表中,可以使用transient(不序列化)或者@TableField(exist=false)

package com.example.demo.entity;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

/**
 * 用户实体类
 *
 * @date: 2020/11/11
 * @author: Li Bin
 */
@Data
@TableName("t_user")
public class User {

    @TableId
    private Long userId;

    @TableField("name")
    private String realName;

    private Integer age;

    private String email;

    private LocalDateTime createTime;

    //备注
    @TableField(exist = false)
    private  transient String remark;

}
原文地址:https://www.cnblogs.com/jiliunyongjin/p/13986264.html