项目需要,字段应该设计为timestamp类型,但自动建表后总是被设置为datetime
Google后,在配置文件(Xxx.hbm.xml)中column添加
sql-type="timestamp" default="CURRENT_TIMESTAMP"
后自动创建表后字段被设定为timestamp,默认为当前时间。
完整字段配置:
<property name="recordTime" type="java.sql.Timestamp"> <column name="recordTime" not-null="true" sql-type="timestamp" default="CURRENT_TIMESTAMP"/> </property>
本文出自 “老谢” 博客,谢绝转载!
原文:http://jormin.blog.51cto.com/6136596/1359647