What's the difference between @CreationTimestamp and @CreatedDate in Spring boot jpa?

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

    @CreationTimestamp
    private LocalDateTime creationTimestamp;
}

In Spring boot entity class
I don't know which one to use
What's the different?

1 Answers

@CreatedDate is a Spring annotation and covered in the reference documentation. It is applicable to all stores covered by Spring Data: JPA, JDBC, R2DBC, MongoDb, Cassandra and so on.

@CreationTimestamp is a Hibernate annotation covered in the reference documentation. It is applicable to Hibernate only.

As far as what they actually do they are pretty much the same with the Spring variant supporting more data types.

Related