-
Notifications
You must be signed in to change notification settings - Fork 0
[#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
base: develop
Are you sure you want to change the base?
Conversation
nilgil
commented
Jun 19, 2025
- 공통 엔티티 추가
- 상품 관련 도메인 엔티티 작성
- 상품 도메인 다이어그램 문서 추가
|
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.
슬랙으로 노티가 올줄 알았는데 😢 늦었습니다.
수고많으셨습니다! 잘 작성해주셨어요 👍👍👍👍
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long = 0 | ||
|
||
@CreationTimestamp | ||
@Column(updatable = false) | ||
val createdAt: LocalDateTime = LocalDateTime.MIN | ||
|
||
@UpdateTimestamp | ||
val updatedAt: LocalDateTime = LocalDateTime.MIN |
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.
요고 의도한대로 잘 동작하려나요~?
@field: UpdateTimestamp
요런 annotation 한 번 확인해봐주세요
abstract class PositionableBaseEntity<T> : | ||
BaseEntity(), | ||
Comparable<T> { | ||
abstract var position: Int |
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.
순서를 가질 수 있는 Entity 를 공통화 하는거 훌륭한 것 같아요 👍👍
Comparable<T> { | ||
abstract var position: Int | ||
|
||
override fun compareTo(other: T): Int = compareValuesBy(this, other, { position }, { createdAt }) |
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.
만약 다른 방식의 정렬이 필요하게되면 어떨까요?
조금 더 변경에 유연한 방식은 없을까요?
fun changePosition(position: Int) { | ||
this.position = position | ||
} |
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.
만약에 position 을 불변(immutable) 으로 하고 싶어서,
val position 으로 정의하고,
original.copy(position = 1) 같은 방식으로 한다면,
어떨것같으세요?
var priceAdjustment: Int = 0, | ||
var stock: Int = 0, |
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.
요고는 DB 와의 상관관계로 볼 때,
DB 에서도 default 값을 0으로 줘야하는 친구들일까요?_?
만약 그렇지 않다면, constructor default 값과 DB 정책이 다를 경우 문제는 없을까요~?
import java.time.LocalDateTime | ||
|
||
@MappedSuperclass | ||
abstract class BaseEntity { |
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.
좋습니다. 👍👍
@MappedSuperclass
는 어떤 상황에서 사용하나요?
@Inheritance
와는 어떤 차이가 있어요~?
|
||
@CreationTimestamp | ||
@Column(updatable = false) | ||
val createdAt: LocalDateTime = LocalDateTime.MIN |
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.
- nullable
- default value : min
- default value : now
각각 어떤 장/단이 있을 것 같으신가유!
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long = 0 | ||
|
||
@CreationTimestamp |
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.
@CreationTimestamp, @UpdateTimestamp 는 hibernate 에서 제공하는 기능이네요.
각각 어떤 시점에 필드가 셋팅될까요~?
Spring Data JPA 에서도
- @CreatedDate
- @LastModifiedDate
이런 어노테이션을 제공하고 있는데 어떤 차이가 있을까요?