Back-End/SpringBoot

[SpringBoot] JPA org.hibernate.LazyInitializationException: could not initialize proxy

코딩콩 2022. 5. 21. 21:39

JPA org.hibernate.LazyInitializationException: could not initialize proxy

발생원인

FetchType.LAZY로 맵핑된 객체를 조회할 때

 

해결방법

구글링 하면 FetchType.EAGER로 바꾸라는 방법도 나오지만,

@Transactional(readOnly = true)

객체 조회하는 클래스(서비스 클래스) 에 위 어노테이션을 추가해서 해결