用的mysql 数据库
Java时间自动填充
@TableField(fill = FieldFill.INSERT,value = "create_date") //创建式更新时间
private Date createDate;
@TableField(fill = FieldFill.INSERT_UPDATE,value = "update_date") //插入式更新时间
private Date updateDate;
@TableLogic
private long deleted;
@Version //乐观锁Version注解
private long version;
@TableField(fill = FieldFill.INSERT)
private Date createDate;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
上面这段不会在sql语句上自动填充时间
而下面这段会自动填充时间
这是不是因为匹配不上时间字段
一个绑定了对应的value,一个没有。绑定了才会有相应的策略。或者可以配置文件中全局配置
需要在实体类字段上设置 @InsertFill、@UpdateFill,以便能在插入和更新时使用当前时间填充
@InsertFill("select now()")
@TableField(fill = FieldFill.INSERT,value = "create_date") //创建式更新时间
private Date createDate;
@InsertFill("select now()")
@UpdateFill("select now()")
@TableField(fill = FieldFill.INSERT_UPDATE,value = "update_date") //插入式更新时间
private Date updateDate;
@TableLogic
private long deleted;
@Version //乐观锁Version注解
private long version;
value的字段是不是不一样,你把value的字段改一下试试