Files
llm-wiki/raw/official-docs/spring-data-jpa-enable-jpa-auditing-api.md

86 lines
6.6 KiB
Markdown

---
title: "official-doc / Spring Data JPA — @EnableJpaAuditing API Reference"
source_type: official-doc
url: https://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/repository/config/EnableJpaAuditing.html
archive_url:
related_branches: [feature-persistence-auditing-contract]
related_projects: []
tags: [official-doc, ca-tmpl, persistence, spring-data, spring-boot]
created: 2026-06-10
---
# official-doc / Spring Data JPA — @EnableJpaAuditing API Reference
> Layer: `raw/` — 외부 자료(공식 문서 / 대기업 기술 블로그)의 **원문 발췌·출처 기록**.
> 검증된 요약은 `/ingest` 후 `wiki/concepts/`에 `source-summary-template` 형식으로 별도 작성. 원본은 raw에 영구 보관.
## Parent / 활용 branch
| Branch | 이 자료가 정당화하는 결정 |
|---|---|
| [[raw/branch-notes/feature-persistence-auditing-contract]] | D4: audit timestamp 의 time-source 를 프로젝트의 injectable `Clock` bean 으로 고정 — `dateTimeProviderRef` 가 custom `DateTimeProvider` bean 을 가리키고, 그 bean 이 Clock 을 wrap 한다 |
## 출처 / Source
- 원본 URL: https://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/repository/config/EnableJpaAuditing.html
- 아카이브 URL: (미제공)
- 저자 / 조직: Thomas Darimont, Oliver Gierke, Greg Turnquist / Spring Data JPA (VMware / Broadcom)
- 발행일: (현재 버전 API 문서 — 버전 고정 URL 아님)
- 마지막 확인일: 2026-06-10
## 왜 저장했는지 / Why archived
`@EnableJpaAuditing``dateTimeProviderRef` 속성이 custom `DateTimeProvider` bean 이름을 받아 `TemporalAccessor` 시간 소스를 교체할 수 있음을 공식 API 문서로 확인. 이는 `Clock` bean 으로 시간 소스를 고정하는 D4 결정의 직접 근거. `auditorAwareRef`, `modifyOnCreate`, `setDates` 속성도 함께 포착해 동일 브랜치의 auditor 및 타임스탬프 설정 결정에 활용.
## 핵심 인용 / Key quotes (verbatim, 3~5문장)
> [annotation-level] "`@EnableJpaAuditing` is an annotation to enable auditing in JPA via annotation configuration."
> [§dateTimeProviderRef] "Configures a `DateTimeProvider` bean name that allows customizing the `TemporalAccessor` to be used for setting creation and modification dates."
> [§auditorAwareRef] "Configures the `AuditorAware` bean to be used to lookup the current principal."
> [§modifyOnCreate] "Configures whether the entity shall be marked as modified on creation. Defaults to true."
> [§setDates] "Configures whether the creation and modification dates are set. Defaults to true."
## Claims Extracted / 추출된 주장
| Claim ID | Claim (이 자료가 직접 말하는 것) | Evidence quote | Strength | Applies to | Does not prove |
|---|---|---|---|---|---|
| C1 | `@EnableJpaAuditing``dateTimeProviderRef` 속성은 `DateTimeProvider` bean 이름을 받아 creation/modification 날짜 기록에 사용할 `TemporalAccessor` 를 커스터마이징할 수 있다 | [§dateTimeProviderRef] "Configures a `DateTimeProvider` bean name that allows customizing the `TemporalAccessor` to be used for setting creation and modification dates." | `official-reference` | Spring Data JPA 감사(auditing) 활성화 시 시간 소스를 교체해야 하는 모든 경우 | `DateTimeProvider` 구현 내에서 `Clock` 을 inject 하는 방법 자체는 증명하지 않음; `Clock` 기반 구현이 올바른지는 별도 검증 필요 |
| C2 | `auditorAwareRef` 속성은 현재 principal 을 조회하기 위한 `AuditorAware` bean 이름을 설정한다 | [§auditorAwareRef] "Configures the `AuditorAware` bean to be used to lookup the current principal." | `official-reference` | `@CreatedBy` / `@LastModifiedBy` 필드 자동 기록이 필요한 경우 | `AuditorAware` 구현이 어떤 방식으로 principal 을 resolve 해야 하는지는 증명하지 않음 |
| C3 | `modifyOnCreate` 는 기본값 `true` 로, entity 생성 시 수정 필드도 함께 기록된다 | [§modifyOnCreate] "Configures whether the entity shall be marked as modified on creation. Defaults to true." | `official-reference` | `@LastModifiedDate` / `@LastModifiedBy` 가 entity 최초 저장 시에도 채워져야 하는 경우 | false 로 설정 시의 정확한 동작 범위 (Hibernate dirty-check 상호작용 등) 는 본 문서만으로 증명 불가 |
| C4 | `setDates` 는 기본값 `true` 로, creation/modification 날짜 자동 기록이 활성화되어 있다 | [§setDates] "Configures whether the creation and modification dates are set. Defaults to true." | `official-reference` | `@CreatedDate` / `@LastModifiedDate` 동작 제어가 필요한 모든 경우 | false 로 설정 시 `auditorAwareRef` 동작에 미치는 영향은 증명하지 않음 |
### Strength 허용값
- `official-reference` — 공식 reference/API 문서 (본 문서 해당)
## Usage Boundaries / 적용 경계
- 이 자료가 직접 증명하는 것:
- `C1`: `dateTimeProviderRef` 속성 존재 + `DateTimeProvider` bean name 을 받는다는 계약
- `C2`: `auditorAwareRef` 속성 존재 + `AuditorAware` bean name 을 받는다는 계약
- `C3`: `modifyOnCreate` 기본값 `true`
- `C4`: `setDates` 기본값 `true`
- 이 자료가 증명하지 않는 것:
- `DateTimeProvider` 구현 내부에서 `Clock` 을 사용하는 방법
- `@EnableJpaAuditing` 이 없을 경우 `@CreatedDate` 어노테이션이 무시되는지 여부
- Spring Boot auto-configuration 이 `@EnableJpaAuditing` 을 자동 등록하는지 여부 (별도 auto-config 문서 확인 필요)
- 내 프로젝트에 적용하려면 추가 확인이 필요한 것:
- ca-tmpl 에서 `ClockDateTimeProvider implements DateTimeProvider` 구현 및 `@Bean` 등록 후 동작 검증
- `dateTimeProviderRef = "clockDateTimeProvider"` 바인딩이 Spring context 로드 시 오류 없이 연결되는지 통합 테스트
## 메모 / Notes
- 이 페이지는 API Javadoc 페이지이므로 prose 설명이 짧다. attribute 당 한 줄 description + default value 가 전부.
- `String dateTimeProviderRef` 의 default 는 `""` (empty string = 커스텀 빈 미설정, 기본 시스템 시간 사용).
- `String auditorAwareRef` 의 default 도 `""` (미설정 시 `@CreatedBy`/`@LastModifiedBy` 미기록).
- 추가로 봐야 할 동일 출처 페이지: `DateTimeProvider` 인터페이스 Javadoc, `AuditorAware` 인터페이스 Javadoc.
## Related / 관련
- [[raw/official-docs/at-transactional-spring-official]] — Spring @Transactional 공식 문서 (persistence 영역 관련)
- 같은 브랜치의 다른 근거 자료: [[raw/branch-notes/feature-persistence-auditing-contract]] 의 Sources 표 참조