This primary key of “id“ is primitive !不建议如此请使用包装类 in Class

2023-08-09 21:33:02 浏览数 (2)

1、原来内容:

代码语言:javascript复制
@Data
@TableName("db_leads")
public class Leads {

    @TableId(value = "id", type = IdType.AUTO)
    private int id;

    @TableField("leads_name")
    private int leadsName;

    @TableField("name")
    private String name;

    @TableField("address")
    private String address;
}

2、更改内容(int —> Integer):

代码语言:javascript复制
private int id;
private Integer id;

3、最后结果:

代码语言:javascript复制
@Data
@TableName("db_leads")
public class Leads {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @TableField("leads_name")
    private int leadsName;

    @TableField("name")
    private String name;

    @TableField("address")
    private String address;
}

0 人点赞