JPA (EntityManager) 및 최대 절전 모드 사용.FetchType.LAZY가 db에서 객체를 가져 오지 않습니다.
3 개의 컬렉션이있는 클래스가 있는데, 하나는 FetchType.EAGER이고 다른 두 개는 LAZY입니다. EAGER에 3 개를 넣으면 하나만 가질 수 있으므로 예외가 발생합니다. 내가 그들에게 물어 때
그래서no session or session was closed: javax.faces.el.EvaluationException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:
, 어떻게 내가이 명 컬렉션을 얻을 수 있습니다 : 내가 게으른 목록 중 하나를 사용하려고 할 때이 길에, 나는 예외가?
내 클래스 :
public class Event implements....
....
....
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name="friendsList")
private List<Long> friends;
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name="carsList")
private List<Long> cars;
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name="housesList")
private List<Long> houses;
나는이 시도하지만 여전히 작동하지
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public IEvent synchronizeCarsList(IEvent companyToSynchronize){
if(companyToSynchronize == null)
throw new IllegalArgumentException();
if(entityManager != null) {
List<Long> cars = companyToSynchronize.getSelectedCarsIdList();
}
return companyToSynchronize;
}
편집 : 하나의 엔티티에 하나 이상의 열망을 배포 (또는 내가로부터 이해에 예외 로그)
Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:94) [:3.6.6.Final]
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:119) [:3.6.6.Final]
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:71) [:3.6.6.Final]
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:54) [:3.6.6.Final]
at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:133) [:3.6.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1914) [:3.6.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1937) [:3.6.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:3205) [:3.6.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:3191) [:3.6.6.Final]
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:348) [:3.6.6.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872) [:3.6.6.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906) [:3.6.6.Final]
... 105 more
감사합니다.
여러 개의 열렬한 요소 컬렉션을 허용하지 않을 이유가 없습니다. 예외는 무엇입니까? – remigio
추가 컬렉션 (처음 것 이상)이 @OrderColumn이 정의되어있는 한 여러 컬렉션을 정의하고 열심히 가져올 수 있어야합니다. @orderClumn과 – Perception
내가 칼럼을 얻을 수있었습니다! FetchType.EAGER가 완벽하게 작동했습니다. 안부 –