반응형
영속성 컨텍스트
-
[JPA] 영속성 컨텍스트스프링프레임워크/jpa 2021. 1. 13. 23:24
EntityManagerFactory Client의 요청이 올 때마다 EntityManager를 생성합니다. EntityManager 데이터베이스 Connection을 사용해서 DB 처리를 진행합니다. Entity의 생명 주기 비영속 (new/transient) 영속성 컨텍스트와 전혀 관계가 없는 새로운 상태 영속 (managed) 영속성 컨텍스트에 Entity가 관리되는 상태 EntityManager.persist(entity) 아직 DB에 저장되지 않고 이후 transaction을 commit한 후에 DB에 저장됩니다. 준영속 (detached) 영속성 컨텍스트에 저장되었다가 분리된 상태 삭제 (removed) 삭제된 상태 EntityManager em = emf.createEntityManager(..