env.set(EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager());
StatefulKnowledgeSession result = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
new JPAWorkingMemoryDbLogger(result);
if (log == null) {
log = new JPAProcessInstanceDbLog();
}
return result;
} else {
StatefulKnowledgeSession result = kbase.newStatefulKnowledgeSession();
logger = new WorkingMemoryInMemoryLogger(result);