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

前端 未结 12 2037
忘了有多久
忘了有多久 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:58

    I fixed the issue by changing the code to

    @Basic(optional = false)
    @Column(name = "LastTouched", insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastTouched;
    

    So the timestamp column is ignored when generating SQL inserts. Not sure if this is the best way to go about this. Feedback is welcome.

提交回复
热议问题