Open
Conversation
yousung1020
reviewed
Apr 10, 2026
| @Entity | ||
| public class Mission { | ||
| @Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long msid; |
Contributor
There was a problem hiding this comment.
기본키 필드 이름을 id로 바꾸시는 것을 추천드립니다! 그 이유는 다음과 같습니다.
- QueryDsl 및 JPQL 사용의 편의성: mission.id처럼 직관적으로 접근할 수 있으며, 공통 인터페이스나 base entity를 만들 때 필드 이름이 통일되어 있으면 관리가 훨씬 편합니다.
- JPA 메서드 쿼리의 특성: 쿼리 메서드를 만들 때 findById가 기본이므로, 필드 이름이 id일 때 가장 자연스럽습니다.
- 일관성 측면: 모든 엔티티의 기본키가 id라면, 다른 개발자들이 코드를 볼 때 "이게 식별자구나"라고 바로 파악할 수 있을 것입니다.
- 종합적으로 생각해본다면, 데이터베이스의 칼럼 이름 자체를 msid와 같이 설정하고자 한다면
@Column(name = "msid")와 같이 작성하시고, 객체지향적인 설계를 위해 자바 객체 필드명은 id로 통일하시는게 좋을 것 같다는 의견입니다!
Suggested change
| private Long msid; | |
| private Long id; |
|
엔티티에 실제 값까지 세세하게 넣은 부분이 좋았습니다. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
키워드
여태 까지는 컨버터가 아닌 DTO와 Entity 에 to dto, 와 to entity 로 변환을 하는 방식을 사용 했엇는데 이런 방법도 있엇다는걸 알게 되어 추후 관련 기능을 구현 할 때는 가능하면 해당 방법으로 하는것이 좋겠다는 생각을 하게 됨
실기
보통 프로젝트 세팅 할 때 작업을 하기 위해서 erd, api 명세서를 핵심 기능 + 최소한의 기능만 작성(개발 하면서 필요에 따라 확장 및 수정이 용이 하도록) 한 다음에 시작하고 진행하면서 뻗어 나가는 형식을 선호하는 편인데,
처음부터 erd가 다 짜져 있는 상태에서 하려니, 전체적인 코드를 어떻게 짤지 생각하는 단계에서 컨트롤러, dto, 엔티티 부분에서 양식이 픽스가 되게 되어 이를 어떻게 첫 단추를 꿰어야 하나 혼동이 와서 엔티티와 레포지토리만 작성하고 제출하게 됨.