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

도메인 구조를 리패키징하고 래핑했습니다. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

K-Diger
Copy link
Member

@K-Diger K-Diger commented Sep 4, 2023

기존 문제점

  • 기존에는 기본 타입을 사용하여 컬럼을 매핑하고있었습니다.
  • 이 내용을 코드를 객체로 래핑하여 각 컬럼에 대한 객체에서 Validation과 협력관계를 구축할 수 있도록 마련할 필요성을 느꼈습니다.

해결 방법

Title이라는 컬럼이 필요하다면 Title이라는 임베디드 타입을 생성하여 자체적으로 그에 대한 값을 검증하는 도메인 로직을 가질 수 있도록 하였고

다른 객체와 상호작용하여 특정 컬럼에 대한 로직을 처리할 수 있도록 구조를 마련했습니다.

추가로 공유할 점

  • 위 내용은 리젝먹을수도 있기 때문에 우선 게시글 관련된 테이블에만 적용했습니다.

리뷰 시원하게 남겨주세요 ^^

@lsakee
Copy link

lsakee commented Sep 4, 2023

LGTM

Copy link
Collaborator

@Hejow Hejow left a comment

Choose a reason for hiding this comment

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

우선 궁금한 것 위주로 리뷰를 달아봤씀당 Diger!

어떤 의도인지 알겠구 좋은 의도라구 판단합니당!
근데 클래스가 너무 많아지는 것에 대해서는 어떻게 생각하는지 궁금하구
지금 당장 필요하지 않는다면 굳이 써야할까? (YAGNI 원칙)라는 생각이 들어서 의견이 궁금합니다
갠적으로 상관없다고는 생각하지만 고려해보는 것도 좋을 것 같아서 남겨봅니다 ㅎㅎ

@@ -11,12 +11,16 @@ import java.time.LocalDateTime
abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null
val id: Long = 0L
Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 안그래도 궁금했던 부분 중 하나..!
JPA에서 Wrapper 타입을 사용하는건 0과 같은 값이 ID일 때 유효한가?에 대한 판단을 위해서인데
이렇게 0을 써도 무방해 부라더?? 잘 모르겠움 😭

Copy link
Member Author

Choose a reason for hiding this comment

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

auto increment는 GenerationType.IDENTITY옵션을 쓰면 전적으로 DBMS가 부여하는 PK를 쓰는걸로 알고있어서 기본값을 0L로 지정해도 무관하다고 알고있어요!

물론 형이 하신대로 하셔도 진짜 노상관이라서 이것도 굳이 반영안하고 형 생각대로 가도 될 것 같아요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

몰라서 물어본거라 편하게 정해도 좋습니다 ㅋㅋ

val id: Long? = null
val id: Long = 0L

@Column(name = "is_deleted")
Copy link
Collaborator

Choose a reason for hiding this comment

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

name을 딱히 매핑해주지 않아도 자동으로 snake_case로 변환해주는데 굳이 붙인 이유가 있을까??

Copy link
Member Author

Choose a reason for hiding this comment

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

하다가 빼먹은 컬럼이 많긴하지만 명시적으로 컬럼을 네이밍하는게 조금 더 보기 좋은 것 같긴해서 써놨어요~

이것도 컨벤션 정해놓으면 좋을것같네요?!

@K-Diger K-Diger marked this pull request as draft September 4, 2023 16:00
@K-Diger
Copy link
Member Author

K-Diger commented Sep 4, 2023

클래스 홍수가 나는건 확실히 좀 복잡해질 순 있긴하겠네요 요고는 회의때 함 말해보는걸로 할까유?!

@K-Diger K-Diger marked this pull request as ready for review September 5, 2023 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants