首页 > mysql使用hiberna插入datetime值

mysql使用hiberna插入datetime值

create_time datetime DEFAULT NULL COMMENT '批次创建时间'
update_time datetime DEFAULT NULL COMMENT '最后更新时间'

record.setCreateTime(new Date());
record.setUpdateTime(new Date());

使用hibernate保存record对象,update_time的值保存到数据库了,但是create_time一直为空,为什么?


设置默认值为当前时间
create_time datetime DEFAULT CURRENT_TIMESTAMP COMMENT '批次创建时间'
或者
create_time timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '批次创建时间'

【热门文章】
【热门文章】