@EnableJpaAuditing
@Configuration
public class JpaAuditingConfig {
}
import jakarta.persistence.*;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime;
@Getter
@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@CreatedDate
@Column(updatable = false)
private LocalDateTime createdAt;
@LastModifiedDate
@Column(insertable = false)
private LocalDateTime updatedAt;
}
์ถ์ ํด๋์ค๋ก ์ง์ ํ ์ด์
- ์์์ ํตํด์๋ง ์ฌ์ฉ๋์ด์ผ ํจ์ ๋ช ํํ ํ๊ธฐ ์ํด์