您的位置:首页技术文章
文章详情页

mysql使用hiberna插入datetime值

【字号: 日期:2022-06-18 15:49:54浏览:54作者:猪猪

问题描述

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一直为空,为什么?

问题解答

回答1:

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

相关文章: