Conversation
| public class MatchPost extends BaseEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "matchPost_id") |
There was a problem hiding this comment.
column이름은 match_post_id가 더 적절한 것 같습니다!
| @Column(name = "title", nullable = false) | ||
| private String title; | ||
|
|
||
| @Column(name = "title", nullable = false) | ||
| private String introduce; | ||
|
|
||
| @Column(name = "title", nullable = false) | ||
| private String appeal; |
There was a problem hiding this comment.
모든 column의 이름이 title이네요!
수정 부탁드립니다~
| @Column | ||
| @Enumerated(EnumType.STRING) | ||
| private MatchPostStatus status; |
There was a problem hiding this comment.
아무런 설정도 필요 없으면 @Column 어노테이션은 지우셔도 될 것 같습니다!
| public MatchPost(Long id, String title, String introduce, String appeal, MatchPostStatus status) { | ||
| Preconditions.checkArgument(title != null, "title must be provided."); | ||
| Preconditions.checkArgument(introduce != null, "introduce must be provided."); | ||
| Preconditions.checkArgument(appeal != null, "appeal must be provided."); | ||
|
|
||
| this.id = id; | ||
| this.title = title; | ||
| this.introduce = introduce; | ||
| this.appeal = appeal; | ||
| this.status = status; | ||
| } |
There was a problem hiding this comment.
status는 기본값이 정해져있기 때문에 생성자를 private으로 바꾸고, 다른 생성자를 만들어 constructor chaining을 하시면 좋을 것 같습니다!
| @JoinColumn(name = "user1_id") | ||
| private Long user1Id; | ||
|
|
||
| @OneToOne | ||
| @JoinColumn(name = "user2_id") | ||
| private Long user2Id; |
There was a problem hiding this comment.
만약 연관관계 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~
| @OneToMany | ||
| @Column(name = "matchPost_id") | ||
| private Long matchPostId; |
There was a problem hiding this comment.
연관관계를 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~
만약 객체를 매핑하고 싶으시다면 타입을 Long -> MatchPost로 변경하시고
@Column -> @JoinColumn으로 변경해주세요~
| @OneToOne | ||
| @JoinColumn(name = "user_id") | ||
| private Long userId; |
There was a problem hiding this comment.
연관관계를 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~
| @Column | ||
| @Enumerated(EnumType.STRING) | ||
| private UserMatchPostRole role; |
There was a problem hiding this comment.
아무런 설정도 필요 없으시면 @Column 어노테이션은 지우셔도 될 것 같습니다!
| @OneToOne | ||
| @JoinColumn(name = "user_id") | ||
| private Long user; | ||
|
|
||
| @OneToMany | ||
| @JoinColumn(name = "tag_id") | ||
| private Long tagId; |
There was a problem hiding this comment.
연관관계를 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "userTag_id") | ||
| private static Long id; |
There was a problem hiding this comment.
Column의 이름은 user_tag_id가 더 적절한 것 같습니다!
No description provided.