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

유저 관련 연관 테이블의 영속성 전이를 수정해줬어요 #249

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

taegyun1995
Copy link
Contributor

@taegyun1995 taegyun1995 commented Aug 18, 2023

개요

유저 관련 연관 테이블의 영속성 전이를 수정해줬어요

📌 관련 이슈

✨ 과제 내용

  • 초기 셋팅 과정에서 영속성 전이를 ALL로 했더니 문제가 많이 생겨서 전체적으로 수정중이에요..

@taegyun1995 taegyun1995 added chore 세팅 관련입니다. refactoring 코드가 내부적으로 작동하는 방식을 변경합니다. cleanup과는 다릅니다. labels Aug 18, 2023
@taegyun1995 taegyun1995 self-assigned this Aug 18, 2023
@OneToOne(mappedBy = "profileImage", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(mappedBy = "pin", fetch = FetchType.LAZY)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

매핑이 잘못되어있었고, 영속성 전이가 여기엔 필요가 없어서 지웠습니다 ~

@OneToOne(mappedBy = "profileImage", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(mappedBy = "profileImage", fetch = FetchType.LAZY)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로필 이미지에도 마찬가지여서 영속성 전이를 제외시켰습니다 ~

Comment on lines -53 to +64
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
@JoinColumn(name = "profile_image_id")
private ProfileImage profileImage;

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
@JoinColumn(name = "pin_id")
private Pin pin;

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
@OneToOne(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private RefreshToken refreshToken;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로필 이미지와, 핀은 유저가 생성될 때 같이 생성되게 PERSIST를 적용시켰고

리프레시토큰과 프로필이미지, 핀은 유저가 삭제될 때 다같이 삭제되어야 해서 REMOVE를 적용 시켜서

필요한것만 적용시켰습니다..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다~!

Comment on lines +66 to +78
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
private List<Link> linkList = new ArrayList<>();

@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
private List<UserHashtag> userHashtagList = new ArrayList<>();

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
private List<Bookmark> bookmarkList = new ArrayList<>();

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
private List<IsLinkRead> isLinkReadList = new ArrayList<>();

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

연관관계가 삭제될 때만 필요하다 느껴서 바꿔주었습니당..

Copy link
Contributor

@esubine esubine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다~

Comment on lines -53 to +64
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
@JoinColumn(name = "profile_image_id")
private ProfileImage profileImage;

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
@JoinColumn(name = "pin_id")
private Pin pin;

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
@OneToOne(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private RefreshToken refreshToken;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다~!

@taegyun1995 taegyun1995 merged commit 1000b80 into dev Aug 18, 2023
2 checks passed
@taegyun1995 taegyun1995 deleted the fix/user branch August 18, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore 세팅 관련입니다. refactoring 코드가 내부적으로 작동하는 방식을 변경합니다. cleanup과는 다릅니다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants