-
Notifications
You must be signed in to change notification settings - Fork 0
OSIV
sdrs6921 edited this page May 26, 2021
·
1 revision
-
OSIV는 트랜잭션 시작 부터 API 응답이 완전히 끝날 때 까지 영속성 컨텍스트와 DB와의 커넥션을 유지하는 전략을 의미 -
JPA 에서는
Session이Entity Manager을 의미하는 데 View가 모두 처리될 때까지영속성 컨텍스트가DB와의 커넥션을 유지 -
장점
-컨트롤러와View레이어까지도 JPA 영속 상태이기 때문에 수정을 제외한 JPA 기술을 사용할 수 있음 -
단점
- 하나의 요청에 대해 너무 오랜 시간 동안 DB와 커넥션 리소스를 사용하기 때문에 API 대기 시간 만큼 리소스를 낭비할 수 있음 -
Spring 에서는 기본적으로
spring.jap.open-in-session-view : true가 기본 값 -
이것 때문에 스프링 웹 어플리케이션을 띄우게 되면 다음과 같은
warning메세지가 뜨게 됨
2021-05-26 13:38:52.443 WARN 4778 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering.
만약 Open In Session View를 Warning 상태로 두기 위해서는
application.yml
spring:
jpa:
open-in-session-view : false이렇게 설정해 주게 되면 open-in-session-view를 사용하지 않도록 바꿀 수 있다.