Last update timestamp with JPA

后端 未结 3 1061
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 08:55

I\'m playing around a bit with JPA(Eclipselink to be specific). The below entity have a timestamp that\'s supposed to reflect whenever that entity was last updated.

3条回答
  •  轮回少年
    2020-12-15 09:12

    if you are using mysql, I think you can do the following to disable the timestamps from being updated from entity

    @Column(name = "lastUpdate", updatable= false, insertable=false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdate;
    

    for oracle you time have to set the timestamps from the entity using @PreUpdate annotation as explained above.

提交回复
热议问题