Spring boot jpa中@CreationTimestamp和@CreatedDate有什么区别?

Bye*_*hoi 7 spring spring-data-jpa

@Entity
public class Foo {
    @CreatedDate
    private LocalDateTime createdDateTime;

    @CreationTimestamp
    private LocalDateTime creationTimestamp;
}
Run Code Online (Sandbox Code Playgroud)

在Spring boot实体类中
我不知道该使用哪一个
有什么不同?

Jen*_*der 11

@CreatedDate是一个 Spring 注释,并在参考文档中进行了介绍。适用于Spring Data覆盖的所有存储:JPA、JDBC、R2DBC、MongoDb、Cassandra等。

@CreationTimestamp是参考文档中介绍的Hibernate 注释。它仅适用于 Hibernate。

就其实际功能而言,它们与支持更多数据类型的 Spring 变体几乎相同。