Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20210613] JPA - BaseEntity #147

Open
JuHyun419 opened this issue Jun 13, 2021 · 0 comments
Open

[20210613] JPA - BaseEntity #147

JuHyun419 opened this issue Jun 13, 2021 · 0 comments
Labels

Comments

@JuHyun419
Copy link
Owner

JuHyun419 commented Jun 13, 2021

@MappedSuperclass(JPA)

https://ict-nroo.tistory.com/129

  • 객체의 입장에서 공통적인 매핑 정보가 필요할 때 사용
    • ex) id, name, 생성시간, 수정시간 등
  • 해당 어노테이션이 적용된 클래스는 테이블 생성 X

AuditingEntityListener

  • JPA 내부에서 엔티티 객체가 생성 및 변경되는 것을 감지하는 역할

@Createdate, @LastModifiedDate

  • 생성 시간 / 최종 수정 시간을 자동으로 처리하는 어노테이션
  • updatable = false --> Entity 객체를 데이터베이스에 반영할 때 해당 컬럼값은 변경되지 않음

@EnableJpaAuditing

  • JPA를 통해 AuditionEntityListener를 활성화시키기 위한 어노테이션
  • 프로젝트 생성시 존재하는 애플리케이션(실행 클래스)에 추가
@MappedSuperclass
@EntityListeners(value = {AuditingEntityListener.class})
@Getter
public class BaseEntity {

    @CreatedDate
    @Column(name = "regdate", updatable = false)
    private LocalDateTime regDate;

    @LastModifiedDate
    @Column(name = "moddate")
    private LocalDateTime modDate;

}

@SpringBootApplication
@EnableJpaAuditing
public class GuestbookApplication {

    public static void main(String[] args) {
        SpringApplication.run(GuestbookApplication.class, args);
    }

}



간단 회고

퇴사하고 2주째도 끝났다.
시간은 여전히 빠르게 지나가고, 2주동안 열심히 한 것 같다.
이번주는 대학 동기들, 고향 친구들좀 만나서 간단히 잡담을 좀 나눴다.
오랜만에 만나서 여러 대화도 나누며 괜찮은 시간을 보낸 것 같다.
24시간 공부하는 것도 좋지만, 그동안 공부하며 느꼈던게 잘 쉬는것도 중요한 것 같다.
열심히 달리되 적당히 쉬면서 꾸준히 페이스를 유지하며 달려야겠다 !
다음주도 화이팅~!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant