Conversation
- MemberServiceImpl의 findById(), findMemberByEmail() 메서드에 @transactional(readOnly = true) 적용 - LogBookService의 getLogBooksByYearAndStatus(), getLogBooks() 메서드에 @transactional(readOnly = true) 적용 근본 원인: - Member 엔티티는 @Version 필드를 가짐 (optimistic locking) - 클래스 레벨 @transactional로 인해 읽기 메서드도 write transaction에서 실행됨 - Write transaction 내에서 @Cacheable로 캐싱된 Member 엔티티가 detached되면서 version 필드 초기화 문제 발생 - 에러: "Detached entity with generated id has an uninitialized version value 'null'" 해결 방법: - 읽기 전용 메서드에 명시적으로 @transactional(readOnly = true) 적용 - 캐시와 JPA 트랜잭션 간 호환성 향상 - 불필요한 write lock 방지로 성능 최적화
캐시에서 가져온 detached Member 엔티티를 저장할 때 @Version 필드가 null이어서 ObjectOptimisticLockingFailureException이 발생하는 문제 수정 변경 사항: - findById(): @transactional(readOnly=true) 제거하여 managed entity 반환 - saveMember(): detached entity 감지 시 DB에서 재조회 후 필드 복사 - updateLevel/requestToDeleteMember/cancelDeleteMember: @CacheEvict에 beforeInvocation=false 명시하여 캐시 무효화 타이밍 명확화
…n-error fix/#194: 캐시 트랜잭션 오류 수정
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 관련 이슈
연관된 이슈 번호를 적어주세요. (예: #123)
📌 PR 요약
PR에 대한 간략한 설명을 작성해주세요.
(예: 해당 변경 사항의 목적이나 주요 내용)
📑 작업 내용
작업의 세부 내용을 작성해주세요.
스크린샷 (선택)
💡 추가 참고 사항
PR에 대해 추가적으로 논의하거나 참고해야 할 내용을 작성해주세요.
(예: 변경사항이 코드베이스에 미치는 영향, 테스트 방법 등)