Java/Framework & Libs
[hibernate] org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags:
허니몬
2016. 11. 9. 12:36
발생문제
org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [entity.list_collection_a, entity.list_collection_b]
해당필드는 enum 타입의 목록을 가지는 필드였고, 프로젝트의 의존성 라이브러리 버전들을 업그레이드 하면서org.hibernate.loader.MultipleBagFetchException 이 발생했다.
업그레이드
org.hibernate:hibernate-entitymanager:5.1.0.Final→org.hibernate:hibernate-entitymanager:5.2.4.Final
해결방법
이 문제를 해결하는 방법은 enum 타입 컬렉션 필드에 정의를 다음과 같이 변경했다.
@ElementCollection 는 기본적으로 LAZY 값을 가진다. 그러나 한단에 선언된@LazyCollection(LazyCollectionOption.FALSE) 을 통해서 EAGER 로 처리된다.@LazyCollection 는 컬렉션 타입에 대한 LAZY 여부를 결정하는 기능을 한다.