, 내가 코드Hibernate가 백킹 빈 <code>edit()</code> 방법에서
public void edit(Entity e) {
this.entity = entityService.find(e);
this.entity.setLazyList(new ArrayList(this.entity.getLazyList()));
}
public Entity getEntity() {
return this.entity;
}
다음 한 같은 요청에 다시 반환 ArrayList를 함께 PersistentBag 교체, 나는 ArrayList
내 자신으로 변경하여 게으른 목록을 초기화 . 이상한 점은 느린 목록 안의 PersistentBag
이 존재하는 즉시 되살아납니다. edit()
방법입니다. 나는이 문제를 찾기 위해 무슨 짓을 :
- 편집 방법에 브레이크 포인터를 놓습니다. 발견 후, 나는 발견 된 엔티티의 JVM ID를보고 101이라고 말합니다.
getEntity()
메소드에 중단 점을 넣습니다.edit()
이 존재하면getEntity()
이 호출되고 엔터티의 JVM ID는 여전히 101이지만entity.lazyList
은ArrayList
대신PersistentBag
이됩니다.
내 LazyList는 a에 바인딩됩니다. 이 PersistentBag는 JSF 페이지에서 save 버튼을 누를 때 LazyInitializationException을 발생시킵니다. 예외 (또한 예외를 발생도에서 MyFaces 시험)의 때문에 인 Mojarra이 부분에서 (저장() 호출 백킹 빈에있어서 전) 발생되어
MenuRenderer 라인 365
// No cloned instance so if the modelType happens to represent a
// concrete type (probably not the norm) try to reflect a
// no-argument constructor and invoke if available.
if (targetCollection == null) {
//noinspection unchecked
targetCollection =
createCollection(currentValue, modelType);
}
불행히도 PersistentBag이기 때문에 createCollection()은 더 이상 세션 및로드 된 객체를 모르는이 객체의 새 인스턴스를 반환합니다.