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

[3장] 영속성 관리 #3

Open
iyoungman opened this issue Oct 17, 2020 · 0 comments
Open

[3장] 영속성 관리 #3

iyoungman opened this issue Oct 17, 2020 · 0 comments

Comments

@iyoungman
Copy link
Contributor

iyoungman commented Oct 17, 2020

엔티티 매니저 팩토리와 엔티티 매니저

엔티티 생명주기

영속성 컨텍스트 특징

  • 식별자

    • 엔티티 식별자 값으로 구분한다.
    • 따라서 영속 상태는 식별자 값이 반드시 있어야 한다.
  • 영속성 컨텍스트 -> DB 저장 시점

    • 트랜잭션 커밋 시점
    • 이를 flush(DB에 반영) 라고 한다.
  • 영속 엔티티가 동일성 보장하는 이유

    • find하면 1차 캐시 조회 -> DB 조회를 한다.
    • 만약 1차 캐시에 없으면 DB 조회한 결과를 1차 캐시에 저장한다.
    • 1차 캐시는 Map 자료구조이다.
      • Map의 Key는 객체 식별자, Value는 객체 인스턴스
    • 아래의 경우 1차 캐시 Map에서 조회하므로 true
    Member m1 = em.find(Member.class, "member1");
    Member m2 = em.find(Member.class, "member1");
    m1 == m2//true, 동일성
  • 변경 감지 과정

플러시

  • 영속성 컨텍스트 변경 내용을 DB에 반영
@iyoungman iyoungman changed the title [3장] 영속성 관리 [3장] 영속성 관리 - iyoungman Oct 17, 2020
@iyoungman iyoungman changed the title [3장] 영속성 관리 - iyoungman [3장] 영속성 관리 Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant