Exception (2) 썸네일형 리스트형 [JPA] failed to lazily initialize a collection 0. 에러 상황 TestCode 작성 중 단순 save - find 코드를 작성했는데 아래와 같은 에러가 발생 failed to lazily initialize a collection of role: com.demo.jpastudy.entity.UserEntity.addressList, could not initialize proxy - no Session org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.demo.jpastudy.entity.UserEntity.addressList, could not initialize proxy - no Session at app//org.hib.. [JPA] Null value was assigned to a property exception 1. 에러 원인 JPA를 사용해 개발을 하다 보면 database column은 nullabel 속성이지만 entity의 field는 primitive 타입으로 설정할 때가 있다. 그럴 때 primitive type에는 null 값을 할당할 수 없어 해당 에러가 발생한다. 2. example Entity 설정 code // TestEntity.java @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Entity public class TestEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private int testPriority; } // TestRep.. 이전 1 다음