일괄 처리 프로그램이 LazyInitializationException
예외를 발생시킵니다. 이것은 매번 발생하지 않습니다. 거의 발생하지 않으며 배치를 다시 실행하면 레코드가 오류없이 처리됩니다.org.hibernate.LazyInitializationException : 프록시를 초기화 할 수 없음 - 세션 없음 - 드물게 발생 함
는 I는 I 레코드의 실제 수보다 큰 수로 (100)로부터 플러시 레코드의 수를 증가하면 다음 코드
private void flushHibernateCache() {
final String CM_FLUSH_HBM_CHACHE = "flushHibernateCache";
final String CM_CLEAR_HBM_CHACHE = "clearHibernateCache";
BigInteger sessionLimit = getParameters().getSESSION_FLUSH_LIMIT();
if (notNull(sessionLimit) && recordsProcessed.mod(sessionLimit).intValue() == 0) {
FrameworkSession session = (FrameworkSession) SessionHolder.getSession();
session.flush(CM_FLUSH_HBM_CHACHE);
session.clear(CM_CLEAR_HBM_CHACHE);
}
}
을 사용하여 처리 된 모든 100 개 개의 레코드에 대한 캐시 플러시있어 처리하려면 오류없이 일괄 처리가 실행됩니다.
18:21:53,687 [BATCHWorker:2] ERROR (com.splwg.base.support.cluster.ClusteredExecutionContext) An error has occurred while processing distributed grid work. A rollback will be issued. Processing of other work will continue.
com.splwg.base.api.batch.ThreadAbortedException: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at com.splwg.base.api.batch.AbstractCommitStrategy.handleReplayableCommit(AbstractCommitStrategy.java:219)
at com.splwg.base.api.batch.AbstractCommitStrategy.__AW_doCommit(AbstractCommitStrategy.java:201)
at com.splwg.base.api.batch.AbstractCommitStrategy.doCommit(AbstractCommitStrategy.java)
at com.splwg.base.api.batch.AbstractCommitStrategy.__AW_concreteExecuteWork(AbstractCommitStrategy.java:75)
at com.splwg.base.api.batch.AbstractCommitStrategy.concreteExecuteWork(AbstractCommitStrategy.java)
at com.splwg.base.api.batch.CommitEveryUnitStrategy.concreteExecuteWork(CommitEveryUnitStrategy.java:36)
at com.splwg.base.api.batch.AbstractExecutionStrategy.__AW_executeWork(AbstractExecutionStrategy.java:243)
at com.splwg.base.api.batch.AbstractExecutionStrategy.executeWork(AbstractExecutionStrategy.java)
at com.splwg.base.support.batch.JavaBatchWork.executeThreadWork(JavaBatchWork.java:109)
at com.splwg.base.support.batch.JavaBatchWork.access$300(JavaBatchWork.java:29)
at com.splwg.base.support.batch.JavaBatchWork$DoExecuteWorkInSession.doBatchWorkInSession(JavaBatchWork.java:92)
at com.splwg.base.support.batch.BatchWorkInSessionExecutable.__AW_run(BatchWorkInSessionExecutable.java:62)
at com.splwg.base.support.batch.BatchWorkInSessionExecutable.run(BatchWorkInSessionExecutable.java)
at com.splwg.base.support.batch.JavaBatchWork.doExecuteWork(JavaBatchWork.java:51)
at com.splwg.base.support.grid.AbstractGridWork.executeWork(AbstractGridWork.java:72)
at com.splwg.base.support.cluster.ThreadWork.processBatchWork(ThreadWork.java:54)
at com.splwg.base.support.cluster.BatchWorkManager.processWork(BatchWorkManager.java:78)
at com.tangosol.coherence.commonj.WorkManager$ScheduleWork.__AW_run(WorkManager.java:2266)
at com.tangosol.coherence.commonj.WorkManager$ScheduleWork.run(WorkManager.java)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.InvocationService.__AW_onInvocationRequest(InvocationService.CDB:12)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.InvocationService.onInvocationRequest(InvocationService.CDB)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.InvocationService$InvocationRequest.run(InvocationService.CDB:1)
at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:1)
at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32)
at com.tangosol.coherence.component.util.DaemonPool$Daemon.__AW_onNotify(DaemonPool.CDB:65)
at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB)
at com.tangosol.coherence.component.util.Daemon.__AW_run(Daemon.CDB:51)
at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:149)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:195)
at org.hibernate.bytecode.cglib.proxy.pojo.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:190)
at org.hibernate.proxy.HibernateProxy$$EnhancerByCGLIB$$c8ddfe27.getThreads(<generated>)
at com.splwg.base.domain.batch.batchRun.BatchThread_Per.getOwningLists(BatchThread_Per.java:191)
at com.splwg.base.support.context.FrameworkSession.__AW_registerChange(FrameworkSession.java:1694)
at com.splwg.base.support.context.FrameworkSession.registerChange(FrameworkSession.java)
at com.splwg.base.support.api.AbstractBusinessEntity.registerChange(AbstractBusinessEntity.java:153)
at com.splwg.base.support.context.FrameworkSession.__AW_registerChanges(FrameworkSession.java:1303)
at com.splwg.base.support.context.FrameworkSession.registerChanges(FrameworkSession.java)
at com.splwg.base.support.context.FrameworkSession.setDTOCalled(FrameworkSession.java:1290)
at com.splwg.base.support.api.AbstractBusinessEntity.completeSetAbstractDTO(AbstractBusinessEntity.java:166)
at com.splwg.base.support.api.AbstractBusinessEntity$2.run(AbstractBusinessEntity.java:281)
at com.splwg.base.support.api.AbstractBusinessEntity$JumpToFrameworkRunner.run(AbstractBusinessEntity.java:372)
at com.splwg.base.support.interception.SessionInterceptionManager.notifyGenericCallStackJump(SessionInterceptionManager.java:290)
at com.splwg.base.support.context.FrameworkSession.notifyGenericCallStackJump(FrameworkSession.java:2311)
at com.splwg.base.support.api.AbstractBusinessEntity.executeCallStackJump(AbstractBusinessEntity.java:298)
at com.splwg.base.support.api.AbstractBusinessEntity.setDTOEtc(AbstractBusinessEntity.java:284)
at com.splwg.base.domain.batch.batchRun.BatchThreadInstance_Per.setDTO(BatchThreadInstance_Per.java:124)
at com.splwg.base.api.batch.AbstractExecutionStrategy.updateUnitsProcessed(AbstractExecutionStrategy.java:140)
at com.splwg.base.api.batch.AbstractExecutionStrategy.updateRestartDataAndCommit(AbstractExecutionStrategy.java:112)
at com.splwg.base.api.batch.AbstractCommitStrategy.saveRestartDataAndCommit(AbstractCommitStrategy.java:259)
at com.splwg.base.api.batch.AbstractCommitStrategy.__AW_doCommit(AbstractCommitStrategy.java:191)
... 27 more
나는이 오류가 발생하는 이유를 식별 할 수 아니에요 :
다음은 오류 로그입니다. 도와주세요.
당신은 어딘가에'fetch = FetchType.LAZY'와 관계를 가지고 있습니다. 관계를 가져 오려면 함수에 DB-Session을 바인드해야합니다. –