2

OpenSessionInViewInterceptor을 사용하여 LazyInitializationException을 피할 수 있습니다."lazily 역할 컬렉션을 초기화하지 못했습니다."OSIV 패턴을 사용할 때도 예외가 발생합니다.

괜찮 았지만 언젠가는 OSIV를 사용할 때도 LazyInitializationException이 발생합니다. 예외는 다음과 같습니다 :

SEVERE: Servlet.service() for servlet [appServlet] in context with path [] 
    threw exception [Request processing failed; nested exception is 
    org.apache.tiles.impl.CannotRenderException: ServletException including path 
    '/WEB-INF/views/home/master.jsp'.] with root cause org.hibernate.LazyInitializationException: 
    failed to lazily initialize a collection of role: com..., 
    no session or session was closed 
     at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersisten 
tCollection.java:383) 
     at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(Abs 
tractPersistentCollection.java:375) 
     at 

예외 로그는 로그 파일에만 있으며 웹 사이트 탐색에는 문제가 없습니다.

어떻게 될까요?

+0

응용 프로그램에서 스레딩을 수행하고 있습니까? OpenSessionInViewInterceptor를 설정 한 applicationContext.xml/web.xml의 관련 부분을 표시 할 수 있습니까? 또한 아마 예외를 던지게하는 코드의 영역을 보는 것을 도울 것입니다. –

답변

0

:

사용 session.merge() 또는

session.refresh() 여기에 일부도 예제가 있습니다. 캐시 된 개체가 분리되었으므로 나중에 초기화되지 않은 일부 속성에 액세스하는 동안 LazyInitializationException이 발생했습니다.