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

[HANSEL-119] Set Version Column & Refactor RegisterReviewStats #122

Open
wants to merge 7 commits into
base: release/v0.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions peauty-domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.assertj:assertj-core'

implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

domain ๋ชจ๋“ˆ์€ ๋ชจ๋“  ๋ชจ๋“ˆ์ด ์ฐธ์กฐํ•˜๊ณ  ์žˆ๋Š” ๋ชจ๋“ˆ์ด๊ธฐ ๋•Œ๋ฌธ์— implemantation ์„ ํ•  ๋•Œ ๋”์šฑ ๋ช…ํ™•ํ•œ ์ด์œ ๊ฐ€ ์žˆ์–ด์•ผ ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค
์ด ์ข…์†์ด ์žˆ๋Š” ์ด์œ ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€์š”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OptimisticLockException์„ ์‚ฌ์šฉํ•ด๋ณด๊ณ ์ž ํ–ˆ์Šต๋‹ˆ๋‹ค.
Domain์— ์ฃผ์ž…ํ•œ ๊นŒ๋‹ญ์€, Domain test์—์„œ ReviewCountingTest๋ฅผ ์ง„ํ–‰ํ•  ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น 'jakarta.persistence:jakarta.persistence-api:3.1.0'์„ implementationํ•ด์•ผ ํ•˜์ง€ ์•Š์„๊นŒ ํ•˜๋Š” ์ƒ๊ฐ์— ์ข…์†์„ ํ–ˆ์Šต๋‹ˆ๋‹ค

Copy link
Contributor

Choose a reason for hiding this comment

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

์šฐ๋ฆฌ๊ฐ€ ์ฒ˜์Œ ์ •ํ–ˆ๋“ฏ์ด domain ๋ชจ๋“ˆ์€ ์™ธ๋ถ€ ๊ธฐ์ˆ ์˜ ์ข…์†์„ ์ตœ์†Œํ™”ํ•˜๊ณ  ์ค‘์š”ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ๋‹ด์€ ์ˆœ์ˆ˜ ์ž๋ฐ” ๊ฐœ๋… ๊ฐ์ฒด๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ฑ…์ž„์„ ๊ฐ€์ง€๊ณ  ์žˆ์–ด์š”
๋‹ค๋งŒ ๋ง์”€ํ•˜์‹  ReviewCountingTest ๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ธฐ์ˆ ์ด ํ•„์š”ํ•œ ๊ฒƒ์ด๋ผ... persistence ๋ชจ๋“ˆ์˜ ์ฑ…์ž„์ด ์•„๋‹๊นŒ ์‹ถ์Šต๋‹ˆ๋‹ค

Copy link
Contributor Author

Choose a reason for hiding this comment

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

๊ทธ๋ ‡๋‹ค๋ฉด ๊ถ๊ธˆํ•œ ๊ฒƒ์ด ์žˆ๋Š”๋ฐ์š”.
๊ธฐ์กด ReviewCountingTest๋ผ๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด์„œ ๋ฆฌ๋ทฐ ๋กœ์ง ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ CRUD๊ฐ€ ์ •์ƒ ์ž‘๋™ํ•˜๋Š”์ง€๋ฅผ ํ…Œ์ŠคํŠธ ํ–ˆ์—ˆ๋Š”๋ฐ์š”.
๊ทธ๋ ‡๋‹ค๋ฉด ๋™์‹œ์„ฑ ์ด์Šˆ๋Š” ํ•ด๋‹น ๋„๋ฉ”์ธ์—์„œ์˜ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ์•„๋‹Œ DB์™€ ์—ฐ๊ด€๋œ ์ด์Šˆ๋ผ๊ณ  ๋ด์•ผํ•˜๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— Persistence์—์„œ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•ด์•ผ ํ•˜๋Š” ๊ฒƒ์ผ๊นŒ์š”?

Copy link
Contributor

Choose a reason for hiding this comment

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

๋งž์•„์š” ๋ฆฌ๋ทฐ์˜ ๋™์‹œ์„ฑ ๋ฌธ์ œ ํ•ด๊ฒฐ์€ ๋น„์ฆˆ๋‹ˆ์Šค๋ผ๊ณ  ๋ณด๊ธฐ ์–ด๋ ต์ฃ !
๋™์‹œ์„ฑ ๋ฌธ์ œ๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์—์„œ์˜ ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค


test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class Review {

private final ID id; // ๋ฆฌ๋ทฐ ID
@Getter private Integer version; // Optimistic Lock
@Getter private final BiddingThread.ID threadId; // ์ž…์ฐฐ ์Šค๋ ˆ๋“œ ID
Copy link
Contributor

Choose a reason for hiding this comment

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

version ์€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋‹จ์—์„œ๋งŒ ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ์œผ๋กœ ์•Œ๊ณ ์žˆ์Šต๋‹ˆ๋‹ค
์ด version ์ด ๋„๋ฉ”์ธ์ธ ํด๋ž˜์Šค์˜ ํ•„๋“œ์— ์žˆ์–ด์•ผํ•˜๋Š” ์ด์œ ๊ฐ€ ์žˆ๋‚˜์š”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

๋˜ ๋„๋ฉ”์ธ๊ณผ ์—”ํ‹ฐํ‹ฐ๋ฅผ ํ•˜๋‚˜์˜ ๊ด€๊ณ„๋ผ๊ณ  ์ƒ๊ฐํ•œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
๋ถ„๋ฆฌํ•ด์„œ ์ƒ๊ฐํ•ด์•ผ ํ•˜๋Š”๋ฐ ์ด๋ฅผ ์ธ์ง€ํ•˜์ง€ ๋ชปํ•˜๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

@Getter private ReviewRating reviewRating; // ๋ณ„์ 
@Getter private String contentDetail; // ์ƒ์„ธ๋ฆฌ๋ทฐ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class ReviewEntity extends BaseTimeEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Version
private Integer version;

@Column(name = "bidding_thread_id", nullable = false)
private Long biddingThreadId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static ReviewEntity toReviewEntity(Review domain){
.reviewRating(domain.getReviewRating())
.contentDetail(domain.getContentDetail())
.contentGeneral(domain.getContentGenerals())
.version(domain.getVersion())
.build();
}

Expand Down Expand Up @@ -50,6 +51,7 @@ public static Review toReviewDomain(ReviewEntity entity, List<ReviewImageEntity>
.reviewImages(reviewImages)
// TODO: null์ด ์•„๋‹Œ๋ฐ null ์ฒดํฌ๋ฅผ ํ•ด์•ผ ํ•˜๋Š” ๊ฒƒ์ด ๋งค์šฐ ์ด์ƒ.
.reviewCreatedAt(entity.getCreatedAt() != null ? LocalDate.from(entity.getCreatedAt()) : null)
.version(entity.getVersion())
.build();

}
Expand Down Expand Up @@ -83,8 +85,6 @@ public static Review toReviewDomain(
.toList())
.reviewRating(reviewEntity.getReviewRating())
.build();


}

}
Expand Down
Loading