Skip to content

[#1] 상품 도메인 엔티티 작성 #4

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

[#1] 상품 도메인 엔티티 작성 #4

wants to merge 6 commits into from

Conversation

nilgil
Copy link
Collaborator

@nilgil nilgil commented Jun 19, 2025

  • 공통 엔티티 추가
  • 상품 관련 도메인 엔티티 작성
  • 상품 도메인 다이어그램 문서 추가

@nilgil nilgil requested a review from f-lab-seb June 19, 2025 22:18
@nilgil nilgil self-assigned this Jun 19, 2025
@nilgil nilgil added the enhancement New feature or request label Jun 19, 2025
@nilgil nilgil linked an issue Jun 19, 2025 that may be closed by this pull request
Copy link

Copy link
Collaborator

@f-lab-seb f-lab-seb 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 +14 to +23
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long = 0

@CreationTimestamp
@Column(updatable = false)
val createdAt: LocalDateTime = LocalDateTime.MIN

@UpdateTimestamp
val updatedAt: LocalDateTime = LocalDateTime.MIN
Copy link
Collaborator

Choose a reason for hiding this comment

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

요고 의도한대로 잘 동작하려나요~?
@field: UpdateTimestamp 요런 annotation 한 번 확인해봐주세요

Comment on lines +6 to +9
abstract class PositionableBaseEntity<T> :
BaseEntity(),
Comparable<T> {
abstract var position: Int
Copy link
Collaborator

Choose a reason for hiding this comment

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

순서를 가질 수 있는 Entity 를 공통화 하는거 훌륭한 것 같아요 👍👍

Comparable<T> {
abstract var position: Int

override fun compareTo(other: T): Int = compareValuesBy(this, other, { position }, { createdAt })
Copy link
Collaborator

Choose a reason for hiding this comment

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

만약 다른 방식의 정렬이 필요하게되면 어떨까요?
조금 더 변경에 유연한 방식은 없을까요?

Comment on lines +13 to +15
fun changePosition(position: Int) {
this.position = position
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

만약에 position 을 불변(immutable) 으로 하고 싶어서,
val position 으로 정의하고,
original.copy(position = 1) 같은 방식으로 한다면,
어떨것같으세요?

Comment on lines +13 to +14
var priceAdjustment: Int = 0,
var stock: Int = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

요고는 DB 와의 상관관계로 볼 때,
DB 에서도 default 값을 0으로 줘야하는 친구들일까요?_?

만약 그렇지 않다면, constructor default 값과 DB 정책이 다를 경우 문제는 없을까요~?

import java.time.LocalDateTime

@MappedSuperclass
abstract class BaseEntity {
Copy link
Collaborator

Choose a reason for hiding this comment

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

좋습니다. 👍👍
@MappedSuperclass 는 어떤 상황에서 사용하나요?
@Inheritance 와는 어떤 차이가 있어요~?


@CreationTimestamp
@Column(updatable = false)
val createdAt: LocalDateTime = LocalDateTime.MIN
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • nullable
  • default value : min
  • default value : now

각각 어떤 장/단이 있을 것 같으신가유!

@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long = 0

@CreationTimestamp
Copy link
Collaborator

Choose a reason for hiding this comment

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

@CreationTimestamp, @UpdateTimestamp 는 hibernate 에서 제공하는 기능이네요.
각각 어떤 시점에 필드가 셋팅될까요~?

Spring Data JPA 에서도

  • @CreatedDate
  • @LastModifiedDate

이런 어노테이션을 제공하고 있는데 어떤 차이가 있을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Product Entity 구현
2 participants