12 KiB
크리에이터 관리자 시리즈 상세 LazyInitializationException 수정 Plan/TASK
| 문서 항목 | 내용 |
|---|---|
| 상태 | 구현 완료 |
| 작성일 | 2026-08-05 |
| 요구사항 기준 | docs/20260805_크리에이터관리자_시리즈상세_LazyInitializationException_수정/prd.md |
| API 기준 | 기존 GET /creator-admin/audio-content/series/{seriesId} 계약 유지 |
| 현재 Phase | Phase 1 완료 |
| 현재 활성 Goal | 없음, 구현 완료 |
목표
OSIV off 환경에서 크리에이터 관리자가 본인 시리즈 상세를 조회할 때 Series.keywordList lazy 초기화 예외 없이 기존 응답을 받게 한다.
현재 상태
| Phase | 상태 | 완료 Task | 활성/다음 Goal | 차단 또는 남은 조건 |
|---|---|---|---|---|
| 1 | 완료 | 1/1 |
없음 | 없음 |
- 동시에 하나의 미완료 goal만 운용한다.
- 완료된 Task와 검증 기록은 되돌리거나 삭제하지 않는다.
범위
포함
CreatorAdminContentSeriesService의 class-level read-only 트랜잭션 경계Series.keywordListlazy 예외를 재현하고 방지하는 서비스 통합 테스트- 기존 상세 응답과 소유권 동작의 영향 범위 회귀 검증
제외
- endpoint와
GetCreatorAdminContentSeriesDetailResponse변경 - OSIV, entity fetch 전략, repository query 변경
- 다른 시리즈 조회·수정 흐름 리팩터링
- 새 abstraction 또는 dependency 추가
기술적 제약
- Kotlin, Java 17, Spring Boot 2.7.14, Spring Data JPA, Hibernate, JUnit 5를 유지한다.
- production code는
CreatorAdminContentSeriesServiceclass-level annotation 한 줄만 변경한다. - 기존 쓰기 메서드
createSeries(),modifySeries(),addingContentToTheSeries(),removeContentInTheSeries(),updateSeriesOrders()의 메서드 레벨@Transactional은 유지해 class-level read-only 기본값을 재정의한다. - 테스트는 실제 Spring 서비스 프록시를 사용하고 외부 테스트 트랜잭션으로 서비스 경계를 가리지 않는다.
- focused test부터 실행하고 직접 영향받는 characterization test까지만 회귀 범위를 확장한다.
- 전체 테스트는 class-level annotation 한 줄 변경과 targeted test로 영향 범위를 판정할 수 있으므로 기본적으로 생략한다. targeted test에서 범위를 설명할 수 없는 실패가 발생하거나 공통 경계 변경으로 확대될 때만 실행한다.
Phase 1: 상세 조회 트랜잭션 회귀 수정
Phase 결과: 크리에이터 관리자 시리즈 상세 조회가 OSIV off 환경에서 키워드를 포함한 기존 DTO를 정상 반환한다.
선행조건: CASD-001~CASD-003 요구사항과 DEC-CASD-002, DEC-CASD-003 결정 확정.
Phase 완료 조건: P1-T1과 P1-GATE 완료, focused·영향 범위 회귀 결과 기록.
구현 항목
Task 1.1 상세 조회 lazy 예외 재현 및 최소 수정
Goal 실행 P1-T1: 서비스 클래스의 기본 read-only 트랜잭션 안에서 상세 조회가 키워드 lazy 컬렉션을 DTO로 변환하게 한다.
- 시작 조건: PRD 구현 기준 확정, production code 미수정 상태.
- 완료 증거: RED/GREEN/REFACTOR 체크박스 완료, focused test 실제 실행 결과, class-level annotation 이외 production diff 없음, 기존 쓰기 메서드 annotation 유지.
- 범위 밖: OSIV·entity mapping·repository query·controller·response DTO 변경.
Files:
- Create:
src/test/kotlin/kr/co/vividnext/sodalive/creator/admin/content/series/CreatorAdminContentSeriesServiceIntegrationTest.kt - Modify:
src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/series/CreatorAdminContentSeriesService.kt - Modify:
docs/20260805_크리에이터관리자_시리즈상세_LazyInitializationException_수정/plan-task.md - Verify:
src/test/resources/application.yml
Interfaces:
-
Consumes:
CreatorAdminContentSeriesService.getDetail(id: Long, memberId: Long)과 기존Series.toDetailResponse(imageHost) -
Produces: 기존 시그니처·DTO를 유지하면서 class-level read-only 트랜잭션 안에서 완성된
GetCreatorAdminContentSeriesDetailResponse -
RED:
@SpringBootTest,EmbeddedRedisInitializer, 실제CreatorAdminContentSeriesService빈을 사용하는 통합 테스트를 작성한다. 테스트 외부 트랜잭션은 사용하지 않고TransactionTemplate안에서 소유 회원, 장르, 시리즈, 해시태그와SeriesKeywordfixture를 저장한 뒤 트랜잭션 밖에서service.getDetail()을 호출해keywords와 주요 상세 필드를 검증한다. -
RED 확인:
./gradlew --no-daemon test --rerun-tasks --tests kr.co.vividnext.sodalive.creator.admin.content.series.CreatorAdminContentSeriesServiceIntegrationTest를 실행해Series.keywordList의LazyInitializationException으로 실패하는지 확인한다. 환경·fixture·컴파일 실패는 RED 증거로 인정하지 않고 먼저 바로잡는다. -
GREEN:
CreatorAdminContentSeriesService클래스 선언 바로 위에 기존 import를 사용하는@Transactional(readOnly = true)한 줄을 추가하고 기존 쓰기 메서드의 메서드 레벨@Transactional을 유지한다. -
GREEN 확인: RED와 같은 focused test를 다시 실행해
BUILD SUCCESSFUL과 fixture의keywords,seriesId,publishedDaysOfWeek,state값 일치를 확인한다. -
REFACTOR: 새 abstraction 없이 테스트 fixture의 중복만 파일 내부 private helper로 제한한다. focused test와
./gradlew --no-daemon test --tests kr.co.vividnext.sodalive.v2.api.admin.aicharacter.series.LegacyCreatorAdminSeriesCharacterizationTest를 실행하고, production diff가 class-level annotation 한 줄이며 모든 기존 쓰기 메서드 annotation이 유지되는지 확인해 결과를 이 Task 아래에 기록한다.
완료 조건
P1-T1의 RED/GREEN/REFACTOR와 완료 증거가 모두 충족됐다.CASD-001~CASD-003이 자동 검증 결과로 추적된다.- API 계약, OSIV, entity mapping, repository query에 변경이 없다.
검증 방법
Phase 1 Gate
Goal 실행 P1-GATE: 상세 조회 수정의 기능·회귀·문서 범위를 최종 판정한다.
- 시작 조건:
P1-T1완료. - 완료 증거: 아래 명령 통과 및 실제 결과를 검증 기록에 누적.
- 범위 밖: Gate 통과를 위한 테스트 완화와 관련 없는 코드 수정.
./gradlew --no-daemon test --rerun-tasks --tests kr.co.vividnext.sodalive.creator.admin.content.series.CreatorAdminContentSeriesServiceIntegrationTest
./gradlew --no-daemon test --tests kr.co.vividnext.sodalive.v2.api.admin.aicharacter.series.LegacyCreatorAdminSeriesCharacterizationTest
./gradlew --no-daemon ktlintCheck
./gradlew --no-daemon tasks --all
git diff --check
./gradlew --no-daemon test
- focused test가 실제 실행되고 failures/errors 0으로 통과한다.
- 기존 시리즈 상세·소유권 characterization test가 통과한다.
ktlintCheck,tasks --all,git diff --check가 통과한다.- ultrawork verification 요구에 따라 전체 테스트를 실행하고 통과했다.
- production code 변경이
CreatorAdminContentSeriesService의 class-level@Transactional(readOnly = true)한 줄뿐이다. - 기존 쓰기 메서드 5개의 메서드 레벨
@Transactional이 유지된다.
실행 순서
| 순서 | Goal | 완료 후 다음 Goal |
|---|---|---|
| 1 | P1-T1 |
P1-GATE |
| 2 | P1-GATE |
구현 완료 |
Progress
- 2026-08-05: 운영 stack trace와 controller → service → repository → entity DTO 변환 흐름을 확인했다.
- 2026-08-05:
Series.keywordListlazy 접근과 트랜잭션 없는getDetail()을 원인으로 확정했다. - 2026-08-05: PRD와 Plan/TASK를 작성했으며 production code와 테스트는 아직 변경하지 않았다.
- 2026-08-05: 메서드 분류 재검토 결과 트랜잭션 없는 public 메서드 4개는 모두 조회이고, 쓰기 메서드 5개는 모두 메서드 레벨
@Transactional을 보유함을 확인했다. 해결안을getDetail()메서드 단위에서 서비스 class-level read-only 기본값으로 정정했다. - 2026-08-05:
P1-T1RED/GREEN/REFACTOR를 완료했다. 다음 Goal은P1-GATE이며 Gate 체크박스는 아직 미완료다. - 2026-08-05:
P1-GATE의 focused·characterization·정적 검사·Gradle task 확인·전체 테스트를 모두 통과해 Phase 1과 구현을 완료했다.
검증 기록
- 문서 작성 시점에는 구현용 RED/GREEN 테스트를 실행하지 않았다.
- 2026-08-05: 문서 변경 후
./gradlew --no-daemon tasks --all로 계획에 사용한 Gradle 명령이 유효한지 확인했다.- sandbox 실행은
/Users/klaus/.gradle/wrapper/dists/.../gradle-8.1.1-bin.zip.lck접근 제한으로 실패했다. - 승인 실행은
BUILD SUCCESSFUL in 8s로 통과했다.
- sandbox 실행은
- 2026-08-05:
git diff --check가 출력 없이 통과했고, 구현 파일과 테스트 파일은 변경하지 않았음을 확인했다. - 2026-08-05: class-level read-only 트랜잭션 기준으로 문서를 보완한 뒤
./gradlew --no-daemon tasks --all을 재실행해BUILD SUCCESSFUL in 7s를 확인했다. - 2026-08-05: production 수정 전 focused test를 실행해
BUILD FAILED in 6m 50s와org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: kr.co.vividnext.sodalive.creator.admin.content.series.Series.keywordList, could not initialize proxy - no Session을 확인했다. - 2026-08-05:
CreatorAdminContentSeriesService에@Transactional(readOnly = true)한 줄을 추가한 뒤 같은 focused test를 재실행해BUILD SUCCESSFUL in 4m 52s를 확인했다. 테스트는 fixture의seriesId,title,introduction,coverImageUrl,publishedDaysOfWeek,genre,keywords,isAdult,state,writer,studio값을 검증한다. - 2026-08-05:
./gradlew --no-daemon test --tests kr.co.vividnext.sodalive.v2.api.admin.aicharacter.series.LegacyCreatorAdminSeriesCharacterizationTest를 실행해BUILD SUCCESSFUL in 47s를 확인했다. - 2026-08-05: production diff는
CreatorAdminContentSeriesService클래스 선언 위의@Transactional(readOnly = true)한 줄뿐이며,createSeries(),modifySeries(),addingContentToTheSeries(),removeContentInTheSeries(),updateSeriesOrders()의 기존 메서드 레벨@Transactional5개가 유지됨을 확인했다. API 계약, OSIV, entity mapping, repository query 변경은 없다. - 2026-08-05:
P1-GATE에서 명령을 순차 실행해 다음 결과를 확인했다../gradlew --no-daemon test --rerun-tasks --tests kr.co.vividnext.sodalive.creator.admin.content.series.CreatorAdminContentSeriesServiceIntegrationTest: exit code 0,BUILD SUCCESSFUL in 4m 44s../gradlew --no-daemon test --tests kr.co.vividnext.sodalive.v2.api.admin.aicharacter.series.LegacyCreatorAdminSeriesCharacterizationTest: exit code 0,BUILD SUCCESSFUL in 41s../gradlew --no-daemon ktlintCheck: exit code 0,BUILD SUCCESSFUL in 30s../gradlew --no-daemon tasks --all: exit code 0,BUILD SUCCESSFUL in 7s.git diff --check: exit code 0, 출력 없음../gradlew --no-daemon test: exit code 0,BUILD SUCCESSFUL in 6m 20s. 기본 계획의 targeted 검증 범위를 넘어 전체 테스트를 실행한 이유는 ultrawork verification 요구사항 때문이다.
- 2026-08-05: Gate 검증 후 production diff가 class-level
@Transactional(readOnly = true)한 줄뿐이고, 새 테스트 파일은CreatorAdminContentSeriesServiceIntegrationTest.kt하나이며, 기존 쓰기 메서드의@Transactional5개가 유지됨을 재확인했다.