当前位置:Gxlcms > 数据库问题 > MySQL创建自动更新列

MySQL创建自动更新列

时间:2021-07-01 10:21:17 帮助过:20人阅读

table `account` ( `id` int primary key auto_increment, `title` varchar(32) not null comment 标题, `price` decimal(6,2) default 0.01 comment 价格, `username` varchar(16) not null comment 账号, `password` varchar(16) not null comment 密码, `create_time` timestamp default current_timestamp comment 创建时间, `update_time` timestamp default current_timestamp on update current_timestamp comment 修改时间 ) comment 账号表;

然后修改对应的实体类,添加@DynamicInsert和@DynamicUpdate注解

@Data
@Entity
@DynamicInsert
@DynamicUpdate
public class Account {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    private String title;
    private BigDecimal price;
    private String username;
    private String password;
    private Date createTime;
    private Date updateTime;
}

 

MySQL创建自动更新列

标签:标题   列表项   count   col   not   update   name   sql   prim   

人气教程排行