Payment-User 관계를 다대일로 수정하여 한 유저의 다중 결제 등록 지원#46
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 타입
구현한 기능
기타
부모-자식 영속성 컨텍스트 동작 원리
연관관계만 맺은 경우
flush() 이전이라면 DB에 insert가 안 되어 있기 때문에, 자식 엔티티를 조회하면 select 쿼리가 날아가지만 DB에 없어서 조회 실패 가능성 있음.
-> (DB 조회가 시도되지만, 아직 DB에 insert가 안 됐기 때문에 못 찾음. 이때는 영속성 컨텍스트에 있어도 프록시 때문에 DB를 보려는 것.)
add를 하면
컬렉션이 메모리에서 채워지는 것 → 즉, 컬렉션 프록시가 영속성 컨텍스트에 등록된 자식 엔티티를 바로 참조하게 되어 select 쿼리가 날리지 않음.
-> (이때는 DB를 조회하지 않고, 영속성 컨텍스트에 있는 객체를 바로 꺼내 쓸 수 있음.)
cascade를 하면
부모 엔티티를 저장할 때, 자식 엔티티도 영속성 컨텍스트에 같이 등록됨. 부모 기준 일괄 동작.
-> (즉, save()만 호출해도 자식까지 영속 상태가 됨.)
orphanRemoval = true
테스트 결과