fix: 설정 수정 시 params/fields unique 제약 위반 수정
Hibernate가 INSERT를 DELETE보다 먼저 실행하는 문제 해결. clear() 후 entityManager.flush()로 DELETE를 먼저 실행 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
부모
9667d3a0ac
커밋
96c69365d3
@ -8,6 +8,7 @@ import com.snp.batch.global.model.BypassApiConfig;
|
||||
import com.snp.batch.global.model.BypassApiField;
|
||||
import com.snp.batch.global.model.BypassApiParam;
|
||||
import com.snp.batch.global.repository.BypassApiConfigRepository;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -25,6 +26,7 @@ import java.util.List;
|
||||
public class BypassConfigService {
|
||||
|
||||
private final BypassApiConfigRepository configRepository;
|
||||
private final EntityManager entityManager;
|
||||
|
||||
/**
|
||||
* 설정 목록 조회
|
||||
@ -101,8 +103,11 @@ public class BypassConfigService {
|
||||
config.setResponseType(request.getResponseType());
|
||||
config.setDescription(request.getDescription());
|
||||
|
||||
// params 교체 (orphanRemoval로 기존 자동 삭제)
|
||||
// params/fields 교체: clear → flush(DELETE 실행) → 새로 추가
|
||||
config.getParams().clear();
|
||||
config.getFields().clear();
|
||||
entityManager.flush();
|
||||
|
||||
if (request.getParams() != null) {
|
||||
request.getParams().forEach(p -> {
|
||||
BypassApiParam param = toParamEntity(p);
|
||||
@ -111,8 +116,6 @@ public class BypassConfigService {
|
||||
});
|
||||
}
|
||||
|
||||
// fields 교체
|
||||
config.getFields().clear();
|
||||
if (request.getFields() != null) {
|
||||
request.getFields().forEach(f -> {
|
||||
BypassApiField field = toFieldEntity(f);
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user