Mapper icon indicating copy to clipboard operation
Mapper copied to clipboard

使用Mybatis-generator 生成model类,其中有一个字段缺失@Column注解。

Open jinyub opened this issue 3 years ago • 3 comments

使用Mybatis-generator 生成model类,其中有一个字段缺失@Column注解,这个是什么原因呀?

生成的Model类如下所示:

@Table(name = "licenses")
public class Licenses {
    @Id
    @Column(name = "license_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "SELECT LAST_INSERT_ID()")
    private String licenseId;

    @Column(name = "license_max")
    private Integer licenseMax;

    @Column(name = "license_allocated")
    private Integer licenseAllocated;

    private String comments;

    @Column(name = "organization_id")
    private String organizationId;

    @Column(name = "license_type")
    private String licenseType;
    ...

其中comments字段没有自动生成@Column注解

jinyub avatar Sep 09 '20 11:09 jinyub

怕不是text类型的字段吧?

zhouxiaofu avatar Sep 11 '20 03:09 zhouxiaofu

怕不是text类型的字段吧?

是varchar呀

jinyub avatar Sep 12 '20 08:09 jinyub

@jinyub 生成model类时,如果数据库中字段名和你生成的model的字段名是一致的,那就不加@Column注解了的。查询时是可以被查询到的

littlefisher666 avatar Sep 21 '20 08:09 littlefisher666