Setting a JPA timestamp column to be generated by the database?

前端 未结 12 2054
忘了有多久
忘了有多久 2020-12-12 23:19

In my SQL Server 2000 database, I have a timestamp (in function not in data type) column of type DATETIME named lastTouched set to getdate()<

12条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 23:57

    If you mark your entity with @DynamicInsert e.g.

    @Entity
    @DynamicInsert
    @Table(name = "TABLE_NAME")
    public class ClassName implements Serializable  {
    

    Hibernate will generate SQL without null values. Then the database will insert its own default value. This does have performance implications See [Dynamic Insert][1].

提交回复
热议问题