Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REFACTOR] 완전 종속되는 요소에 대한 양방향 전환 #88

Closed
lcqff opened this issue Jan 25, 2025 · 0 comments · Fixed by #90
Closed

[REFACTOR] 완전 종속되는 요소에 대한 양방향 전환 #88

lcqff opened this issue Jan 25, 2025 · 0 comments · Fixed by #90
Assignees
Labels
🛠️ Refactor 리팩토링

Comments

@lcqff
Copy link
Member

lcqff commented Jan 25, 2025

현재 SOFO의 연관관계 구성은 자식 요소가 부모 요소를 참조하는 식의 단방향 1:N으로 구성되어있습니다.
이는 이후 필요가 있을시 단방향을 양방향으로 바꾸는 식으로 연관관계의 복잡성을 줄이기 위함이었으나 부모요소 삭제 시 완전 종속되는 자식 요소가 함께 삭제되지 않는 문제가 발생했습니다.

비지니스 코드에서 자식 요소를 삭제할수도 있으나, 과거 경험으로는 자식 객체를 비즈니스 로직으로 삭제하는 경우 삭제를 빠뜨리는 실수가 빈번하게 발생했기에 해당 방식은 제외합니다.

현재 완전 종속되는 자식 요소가 다른 부모 요소를 가지게 될 계획은 없으므로 연관관계를 일대다로 변경하고 연관 관계 매핑 특성을 사용하여 자동으로 삭제되도록 처리합니다.

또한 외래키 불일치를 피하기 위해 일대다 단방향이 아닌 일대다 양방향으로 개발합니다.

리팩토링 내용

자식 요소가 상위 요소에 완전 종속되는 경우 (ex. Album <- Track, Playlist <- PlaylistItem) 다대일 단방향에서 일대다 양방향으로 전환한다.

@lcqff lcqff added the 🐞 Bug 버그 발생 label Jan 25, 2025
@lcqff lcqff self-assigned this Jan 25, 2025
@lcqff lcqff added 🛠️ Refactor 리팩토링 and removed 🐞 Bug 버그 발생 labels Feb 4, 2025
@lcqff lcqff changed the title [BUG] Track이 soft delete될시 Playlist Item이 함께 delete되지 않는 문제 [REFACTOR] 양방향 전환 Feb 4, 2025
@lcqff lcqff changed the title [REFACTOR] 양방향 전환 [REFACTOR] 완전 종속되는 요소에 대한 양방향 전환 Feb 4, 2025
lcqff added a commit that referenced this issue Feb 5, 2025
lcqff added a commit that referenced this issue Feb 5, 2025
lcqff added a commit that referenced this issue Feb 5, 2025
lcqff added a commit that referenced this issue Feb 5, 2025
lcqff added a commit that referenced this issue Feb 5, 2025
lcqff added a commit that referenced this issue Feb 5, 2025
@lcqff lcqff closed this as completed in #90 Feb 5, 2025
lcqff added a commit that referenced this issue Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ Refactor 리팩토링
Projects
None yet
1 participant