springboot 3.2.1
@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseTimeEntity {
@Column(nullable = false)
@CreatedDate
private String createdAt;
@Column(nullable = false)
@LastModifiedDate
private String modifiedAt;
@PrePersist
public void onPrePersist() {
this.createdAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
this.modifiedAt = createdAt;
}
@PreUpdate
public void onPreUpdate() {
this.modifiedAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
}
@EnableJpaAuditin 추가