protected StatefulKnowledgeSession disposeAndReloadSession(StatefulKnowledgeSession ksession,
KnowledgeBase kbase) {
int sessionId = ksession.getId();
ksession.dispose();
EnvironmentBuilder envBuilder = new KnowledgeSessionStorageEnvironmentBuilder( storage );
Environment env = KieServices.Factory.get().newEnvironment();
env.set( EnvironmentName.TRANSACTION_MANAGER,
envBuilder.getTransactionManager() );
env.set( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER,
envBuilder.getPersistenceContextManager() );
return JPAKnowledgeService.loadStatefulKnowledgeSession( sessionId, kbase, null, env );
}