뭐든지시작이반이다
Dream Future
뭐든지시작이반이다
  • 분류 전체보기
    • Spring
      • 개념
      • 기타
    • Java
    • Algorithm
      • 알고리즘 정리
    • DB
      • Postgresql
    • 트러블슈팅
    • Git & Github
    • V&V
    • EFK
    • 북스터디
    • 기타

인기 글

최근 댓글

전체 방문자
오늘
어제

블로그 메뉴

  • 홈
  • 태그
  • 방명록

태그

  • auditing
  • spring-boot
  • docker
  • dirtyChecking
  • 알고리즘
  • SqlSessionFactory
  • 트러블슈팅
  • lombok
  • springbot
  • git
  • Hibernate
  • spring
  • gradle
  • Kibana
  • sqlSessionTemplate
  • 대규모서비스
  • requestmapping
  • Controller
  • JPA
  • multimodule
  • springboot
  • SelectionSort
  • mybatis
  • efk
  • fluentd
  • ambiguous오류
  • github
  • 파티셔닝
  • Kotlin
  • gitignore
hELLO · Designed By 정상우.
뭐든지시작이반이다
Spring/개념

JPA Auditing 이란?

Spring/개념

JPA Auditing 이란?

2022. 1. 14. 18:55

Audit : 감시, 감사하다.


Spring Data provides sophisticated support to transparently keep track of who created or changed an entity and when the change happened. To benefit from that functionality, you have to equip your entity classes with auditing metadata that can be defined either using annotations or by implementing an interface.

Spring Data JPA ships with an entity listener that can be used to trigger the capturing of auditing information. 중략...
You can also enable the AuditingEntityListener on a per-entity basis by using the @EntityListeners annotation, as follows:

Spring Data에서는 entity를 누가 생성/변경했는지, 해당 사건이 언제 발생하였는지를 추적하는 기능을 정교하게 제공하고있다. annotation을 사용하거나 인터페이스를 구현하는 것으로 해당 기능을 사용할 수 있다.

Spring Data JPA는 위의 기능을 수행하는데 사용될 entity listener를 제공한다. @EntityListeners annotations을 이용하여 entity 별로 AuditingEntityListener를 활성화할 수 있다.

밑은 해당 예시이다.

@Entity
@EntityListeners(AuditingEntityListener.class)
public class MyEntity {

}

As of Spring Data JPA 1.5, you can enable auditing by annotating a configuration class with the @EnableJpaAuditing annotation.

Spring Data JPA 1.5 부터 configuration class에 @EnableJpaAuditing annotation으로 auditing을 활성화 할 수 있다.

참고 : @SpringBootApplication 가 @configuration을 포함하고 있다.
(https://spring.io/guides/gs/spring-boot/ 의 Create an Application class 부분)

밑은 해당 예시이다.

@SpringBootApplication // main class of project. 이 annotation 위치부터 설정을 읽어 항상 프로젝트 최상단에 클래스가 위치해야한다.
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args); //내장 WAS 실행
    }
}

위 내용은 아래 링크의 내용을 참고하였다.

https://docs.spring.io/spring-data/jpa/docs/2.5.2/reference/html/#auditing

 

Spring Data JPA - Reference Documentation

Example 109. Using @Transactional at query methods @Transactional(readOnly = true) interface UserRepository extends JpaRepository { List findByLastname(String lastname); @Modifying @Transactional @Query("delete from User u where u.active = false") void del

docs.spring.io

 

저작자표시 비영리 동일조건 (새창열림)

'Spring > 개념' 카테고리의 다른 글

IoC 제어의 역전  (0) 2022.04.14
gradle 개념 정리  (0) 2022.01.03
    'Spring/개념' 카테고리의 다른 글
    • IoC 제어의 역전
    • gradle 개념 정리
    뭐든지시작이반이다
    뭐든지시작이반이다
    기록장입니다.

    티스토리툴바

    단축키

    내 블로그

    내 블로그 - 관리자 홈 전환
    Q
    Q
    새 글 쓰기
    W
    W

    블로그 게시글

    글 수정 (권한 있는 경우)
    E
    E
    댓글 영역으로 이동
    C
    C

    모든 영역

    이 페이지의 URL 복사
    S
    S
    맨 위로 이동
    T
    T
    티스토리 홈 이동
    H
    H
    단축키 안내
    Shift + /
    ⇧ + /

    * 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.