hibernate自动建表设定字段类型为timestamp

项目需要,字段应该设计为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>


本文出自 “老谢” 博客,谢绝转载!

你可能感兴趣的:(java,Hibernate,Timestamp)