Skip to content

πŸš€ 3단계 - μˆ˜κ°•μ‹ μ²­(DB 적용) #756

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 2 commits into
base: gukin-han
Choose a base branch
from

Conversation

gukin-han
Copy link

μ•ˆλ…•ν•˜μ„Έμš” λ¦¬λ·°μ–΄λ‹˜!

3단계 λ―Έμ…˜μ€ DB와 λ„λ©”μΈμ˜ 뢄리 감각을 λŠκ»΄λ³΄λŠ”κ²Œ μ˜λ„μΈκ²ƒ κ°™μŠ΅λ‹ˆλ‹€.

λ„ˆλ¬΄ μ‹œκ°„ λΊκΈ°λŠ”κ²ƒ κ°™μ•„μ„œ μ„œλΉ„μŠ€ λ ˆμ΄μ–΄μ—μ„œ ν•„μš”λ‘œ ν•˜λŠ” DAO의 λ©”μ„œλ“œλ§Œ μ΅œμ†Œν•œμœΌλ‘œ κ΅¬ν˜„ν–ˆμ–΄μš”. μ•„λž˜λŠ” μ œκ°€ μƒκ°ν•˜λŠ” 이 λ―Έμ…˜μ—μ„œ μ–»μ–΄κ°€μ•Όν•  생각듀을 μ •λ¦¬ν•΄λ³΄μ•˜μŠ΅λ‹ˆλ‹€.

μ–»μ–΄μ•Ό ν•  κ΅ν›ˆ μ„€λͺ…
도메인 객체 섀계와 DB ν…Œμ΄λΈ” μ„€κ³„λŠ” λ‹€λ₯΄λ‹€ 객체지ν–₯슀럽게 μ„€κ³„ν•˜κ³ , DBλŠ” ID둜 μ—°κ²°
ID μ €μž₯ vs 객체 μ°Έμ‘°λ₯Ό κ΅¬λΆ„ν•˜λŠ” 감각 무쑰건 객체λ₯Ό λ“€κ³  λ‹€λ‹ˆλŠ” 게 μ•„λ‹ˆλ‹€
도메인 λͺ¨λΈμ„ μ§€ν‚€λ €λ©΄ 쿼리 2~3번 λ‚˜κ°€λ„ κ°μˆ˜ν•  수 μžˆμ–΄μ•Ό ν•œλ‹€ 섀계 > μ„±λŠ₯ (초기 κΈ°μ€€)

Copy link

@ksy90101 ksy90101 left a comment

Choose a reason for hiding this comment

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

κ°„λ‹¨ν•œ ν”Όλ“œλ°±μ„ λ‚¨κ²ΌμŠ΅λ‹ˆλ‹€~ 확인 ν•œλ²ˆ λΆ€νƒλ“œλ¦½λ‹ˆλ‹€!


import java.time.LocalDateTime;

public class EnrolledStudent {

Choose a reason for hiding this comment

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

ꡳ이 Enrolledλ₯Ό 뢙일 μ΄μœ κ°€ μžˆμ„κΉŒμš”?
Studentλ‘œλ§ŒμœΌλ‘œλ„ μΆ©λΆ„νžˆ 도메인 μ„€λͺ…이 κ°€λŠ₯ν•΄ λ³΄μ—¬μ„œμš”~

public class EnrolledStudent {
private Long id;

private String userId;

Choose a reason for hiding this comment

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

객체지ν–₯적으둜 Userλ₯Ό κ°€μ§€κ³  있게 ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

String sql = "INSERT INTO enrolled_student (session_id, user_id, enrolled_at) VALUES (?, ?, ?)";
jdbcTemplate.update(
sql,
enrolledStudent.getSession().getId(), // session κ°μ²΄μ—μ„œ id 꺼냄

Choose a reason for hiding this comment

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

λ””λ―Έν„°μ˜ 법칙을 μœ„λ°˜ν•œκ²ƒ κ°™μŠ΅λ‹ˆλ‹€.
λ”°λ‘œ Id만 λΉΌλŠ” getterλ₯Ό λ§Œλ“œμ‹œλ©΄ μ–΄λ–¨κΉŒμš”?

Comment on lines +28 to +33
CoverImage coverImage = new CoverImage(
rs.getInt("cover_image_size"),
ImageType.valueOf(rs.getString("cover_image_type")),
rs.getInt("cover_image_width"),
rs.getInt("cover_image_height")
);

Choose a reason for hiding this comment

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

CoverImageκ°€ μž¬μ‚¬μš©λ  일이 μ—†μ„κΉŒμš”?
μ •κ·œν™” κ΄€μ μ—μ„œ ν•œλ²ˆ κ³ λ―Όν•΄λ³΄μ…¨μœΌλ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€.

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.

2 participants