OSIV이란?JPA의 OSIV(Open Session In View) 는 웹 요청이 시작될 때 영속성 컨텍스트(EntityManager)를 생성하고, 응답이 끝날 때까지 유지하는 패턴이다. OSIV 설정 방법 아래는 Spring Boot 환경에서 yaml 파일에 대한 설정 방법이고, Spring Boot에서는 기본적으로 OSIV가 활성화되어 있다.spring: jpa: open-in-view: trueOSIV가 필요한 이유 JPA의 연관관계가 LAZY 로딩일 때 문제가 발생할 수 있다.// 엔티티@Entitypublic class Order { @ManyToOne(fetch = FetchType.LAZY) private Member member;}// 서비스@Transactionalpu..
Java/JPA
2026. 6. 3. 23:37