Spring, JPA 🌱

영속성 컨텍스트란?“엔티티를 영구 저장하는 환경”이라는 뜻EntityManager.persist(entity) : 엔티티를 영속성 컨텍스트에 저장EntityManager를 통해서 영속성 컨텍스트에 접근엔티티의 생명주기비영속 (new/transient)영속성 컨텍스트와 전혀 관계가 없는 새로운 상태영속 (managed)영속성 컨텍스트에 의해 관리되는 상태em.persist(Member);를 하면 이 상태가 됨준영속(detached)영속성 컨텍스트에 저장되었다가 분리된 상태삭제 (removed)삭제된 상태비영속 (new/transient)객체를 생성만 하고 EntityManager에 넣지 않은 상태영속 (managed)객체가 영속 컨텍스트에 의해 관리되고 있는 상태em.persist(member)를 하면 E..
JPA 구동 방식먼저 Persistence라는 클래스를 만듦여기서 META-INF/persistence.xml에 있는 설정 정보를 읽어서 EntitiyManagerFactory라는 클래스를 만듦그리고 EntityManagerFactory에서 필요할 때마다 EntityManager 생성META-INF/persistence.xmlCopy --> 여기서 설정 정보 조회JpaMainCopypackage hellojpa;import jakarta.persiste..