Skip to content

[4기 박현지] Mission 2: 영속성 컨텍스트 #263

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 3 commits into
base: hyeon-z
Choose a base branch
from

Conversation

hyeon-z
Copy link

@hyeon-z hyeon-z commented Jul 26, 2023

📌 과제 설명

영속성 컨텍스트 관련 테스트 작성

👩‍💻 요구 사항과 구현 내용

  • 저장 (persist)
  • 조회 (1차캐시 이용)
  • 조회 (detach 사용, DB 이용)
  • 수정 (dirty check 적용)
  • 수정 (dirty check 적용 안됨)
  • 삭제 (remove)

✅ 피드백 반영사항

✅ PR 포인트 & 궁금한 점

@hyeon-z hyeon-z requested review from juno-junho and beomukim July 26, 2023 07:19
@hyeon-z hyeon-z self-assigned this Jul 26, 2023
@hyeon-z hyeon-z changed the title [4기 박현지] 영속성 컨텍스트 [4기 박현지] Mission2: 영속성 컨텍스트 Jul 26, 2023
@hyeon-z hyeon-z changed the title [4기 박현지] Mission2: 영속성 컨텍스트 [4기 박현지] Mission 2: 영속성 컨텍스트 Jul 26, 2023
Copy link

@beomukim beomukim left a comment

Choose a reason for hiding this comment

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

LGTM👍

Copy link

@juno-junho juno-junho left a comment

Choose a reason for hiding this comment

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

LGTM!


@BeforeEach
void setUp() {
repository.deleteAll();

Choose a reason for hiding this comment

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

반복되는 EntityManager 생성을 setup method를 통해서 하는건 어떨까요?

Copy link
Author

@hyeon-z hyeon-z Jul 27, 2023

Choose a reason for hiding this comment

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


transaction.commit();

transaction.begin();

Choose a reason for hiding this comment

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

삭제에 대한 검증이니 transaction.begin()은 remove() 전에 선언하는것은 어떨까요?
find()는 굳이 transaction 안에 있지 않아도 되니까요..!

Copy link
Author

@hyeon-z hyeon-z Jul 27, 2023

Choose a reason for hiding this comment

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

첫 번째 find문은 persistcommit했을 때 잘 저장됐음을 확인하기 위함이고 현재 begin()remove()위에 있는데 혹시 어떤 부분을 말씀하시는 걸까요..?

Comment on lines 18 to 22
@Autowired
CustomerRepository repository;

@Autowired
EntityManagerFactory emf;

Choose a reason for hiding this comment

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

두 개를 다 사용하는 이유가 있나요?

Copy link
Author

@hyeon-z hyeon-z Jul 27, 2023

Choose a reason for hiding this comment

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

CustomerRepository의 메서드로도 가능한데 강의 때 영속성 컨텍스트의 생명주기에 대해 학습해서 EntityManagerFactory를 사용해서 명시적으로 구현헀습니다!

Choose a reason for hiding this comment

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

정확히 테스트하고 싶은 범위는 어떻게 되나요??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants