Repository navigation
fix: 롤 배정 목록 처리를 단일 트랜잭션으로 묶음 - #92
Merged
Merged
Conversation
jei007
approved these changes
Sep 18, 2026
jei007
left a comment
Contributor
There was a problem hiding this comment.
표준프레임워크에 대한 지속적인 참여에
대단히 감사드립니다.
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.
수정 사유 Reason for modification
수정된 소스 내용 Modified source
EgovRoleInfoAPIController.roleInfoInsert는 화면에서 세미콜론으로 이어 보낸 롤 배정 목록을 항목마다 순회하며, 각 항목에서 서비스의delete·insert를 직접 호출합니다.insert·delete는 각각@Transactional입니다.컨트롤러가 서비스 빈(프록시)의 메서드를 항목마다 호출하므로,
@Transactional은 호출마다 새 트랜잭션을 엽니다.regYn="Y"인 항목은 delete와 insert가 서로 다른 트랜잭션이라, delete 다음 insert에서 예외가 나면 그 롤 배정이 insert 없이 영구히 사라집니다. 항목이 여러 개면 이미 처리된 앞쪽 항목은 롤백되지 않고, 예외가 난 항목 뒤는 아예 처리되지 않습니다. 이 프로젝트는 AspectJ 로드타임 위빙을 쓰지 않아(-javaagent설정·@EnableTransactionManagement(mode=ASPECTJ)없음)@Transactional은 기본값인 프록시 기반으로 동작합니다.서비스에 배치 메서드를 추가해, 컨트롤러의 루프를 서비스 메서드 하나 안으로 옮겼습니다. 프록시 기반 AOP는 같은 인스턴스 안의 자기호출(
this.delete(...))을 가로채지 않으므로, 안쪽delete·insert는 새 트랜잭션을 열지 않고updateRoleInfoList가 연 트랜잭션 하나를 그대로 씁니다.컨트롤러는 이 메서드 하나만 호출합니다.
JUnit 테스트 JUnit tests
EgovAuthorRoleRepository를 Mockito로 스텁해EgovAuthorRoleServiceImplUpdateListTest를 추가했습니다.regYn="Y"인 항목마다 delete·insert가 순서대로 불리는지,regYn이 그 외 값이면 delete만 불리고 save는 안 불리는지 확인합니다.수정 전(RED, 배치 메서드가 delete만 하도록 되돌려 재현):
수정 후(GREEN):
같은 모듈의 기존 테스트 2건(
EgovAuthorGroupServiceImplTest·EgovAuthorGroupInfoServiceImplTest)은@SpringBootTest로 로컬 MySQL 접속이 필요한데, 이 환경에는 그 DB가 떠 있지 않아 origin/main 기준으로도 이미 실패합니다. 이 변경과 무관합니다.테스트 브라우저 Test Browser
JUnit 테스트로 대체합니다.
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
위 JUnit 테스트 실행 결과로 대체합니다.