How to create an auto-generated Date/timestamp field in a Play! / JPA?

后端 未结 3 2233
说谎
说谎 2020-12-14 18:56

I\'d like to add a Date/DateTime/Timestamp field on an entity object, that will be automatically created when the entity is created/persisted and set to \"now\", never to be

3条回答
  •  北海茫月
    2020-12-14 19:21

    I think it's a little bit clearly

        @Column(name = "created_at")
        @CreationTimestamp
        private LocalDateTime createdAt;
    
        @Column(name = "updated_at")
        @UpdateTimestamp
        private LocalDateTime updatedAt;
    

提交回复
热议问题