-
Notifications
You must be signed in to change notification settings - Fork 1
기존 Getter의 영향을 받아서 영속화 과정에서 원치않게 저장됨 #330
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 변경으로 영속성 문제는 해결됩니다. 하지만 근본적인 원인은
getPhoneNumber()메소드가 이름과 달리 필드 값을 그대로 반환하지 않고 변형하기 때문입니다. 이는 혼란을 야기하고 잠재적인 버그의 원인이 될 수 있습니다.더 명확하고 유지보수하기 좋은 코드를 위해 관련 메소드들을 리팩토링하는 것을 고려해보시는 건 어떨까요? 예를 들어, 다음과 같이 수정할 수 있습니다.
getPhoneNumber()를getDisplayPhoneNumber()와 같이 변형된 값을 반환함을 명시하는 이름으로 변경합니다.getOriginPhoneNumber()를getPhoneNumber()로 변경하여 실제 필드 값을 반환하는 표준 getter 역할을 하도록 합니다.getPhoneNumberWithoutHyphen()에서는getDisplayPhoneNumber()를 호출하도록 수정합니다.이렇게 리팩토링하면, JPA가 프로퍼티로 접근하더라도 표준 getter인
getPhoneNumber()를 호출하게 되어 원본 값이 올바르게 처리됩니다. 결과적으로@Access(AccessType.FIELD)어노테이션 없이도 문제를 해결할 수 있습니다.리팩토링 예시:
이러한 리팩토링은 코드의 의도를 더 명확하게 만들어 장기적으로 도움이 될 것입니다.