gamenome-project / gamenome-project-server

gamenome-project-server
0 stars 1 forks source link

StarScore의 복합키 데이터 베이스 생성시에 null one-to-one property 발생 현상 #86

Closed Ppajingae closed 1 month ago

Ppajingae commented 1 month ago

이슈 설명

복합키로 엮여있는 상황에서 comment에서 Create 시도시에 null 일대일 속성에서 ID를 할당하려고 시도 애러가 발생

error : attempted to assign id from null one-to-one property 애러 발생

진행사항

기타

Ppajingae commented 1 month ago

타임라인

  1. Comment -> entitynotfoundexception unable to find with id 0 애러 발생
    • 코맨트가 Id가 0으로 Entity를 찾는 문제 발생
    • 해결
      • 해당 부분은 코드로 문제가 없고 복합키를 설정하는 과정에서 0을 조회하는 현상, @NotFound Annotation 을 사용하여 해당 현상 해결
  2. user -> duplicated primary key 애러 발생
    • user가 primary key로 설정이 되어 중복 값이 발생하여 발생된 애러
    • 해결
    • 기존에 작업 실수로 user가 primary key로 들어가 있는 부분 확인 하고 제외 처리 진행
  3. comment -> attempted to assign id from null one-to-one property 애러 발생
    • 1:1 맵핑 관계에서 코맨트의 ID가 null을 할당하려고 시도
    • comment가 create 하는 과정에서 동시에 star_score도 create 가 되는 로직에서 comment가 create 이후에 star_score도 create 이후에 comment 데이터에도 null값이 할당 되는 문제 발생
    • 해결
    • cascodetype.MERGE 를 사용하여 부모 Entity가 생성을 시도 할 때 자식 Entity도 병합하여 생성 시도 할 수 있게 끔 조치
Ppajingae commented 1 month ago

해당 이슈는 종료 처리 하겠습니다