@CreatedDate @LastModifiedDate null값 문제

이효곤·2023년 4월 1일

트러블슈팅

목록 보기
1/7
@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseTimeEntity {

    @CreatedDate
    private LocalDateTime createdAt;

    @LastModifiedDate
    private LocalDateTime updatedAt;
}

의 코드를 상속받아서 사용하는 Entity를 생성 시
createdAt와 updatedAt의 값을 db에서 확인해보니 null값이 들어가 있었다.

해결방법


@SpringBootApplication
@EnableJpaAuditing
public class SummerApplication {

}

Main 클래스에 @EnableJpaAuditing 어노테이션을 추가하면 해결.

참조: https://velog.io/@vpdls1511/BaseEntity-%EC%A0%81%EC%9A%A9-%EC%8B%9C-NULL%EA%B0%92-%EB%93%A4%EC%96%B4%EA%B0%90

profile
develop

0개의 댓글