Source:
<code>public ProcessInstance from(org.activiti.engine.runtime.ProcessInstance internalProcessInstance) { ProcessInstanceImpl processInstance = new ProcessInstanceImpl(); processInstance.setId(internalProcessInstance.getId()); processInstance.setName(internalProcessInstance.getName()); processInstance.setDescription(internalProcessInstance.getDescription()); processInstance.setProcessDefinitionId(internalProcessInstance.getProcessDefinitionId()); processInstance.setInitiator(internalProcessInstance.getStartUserId()); processInstance.setStartDate(internalProcessInstance.getStartTime()); processInstance.setProcessDefinitionKey(internalProcessInstance.getProcessDefinitionKey()); processInstance.setBusinessKey(internalProcessInstance.getBusinessKey()); processInstance.setStatus(calculateStatus(internalProcessInstance)); processInstance.setProcessDefinitionVersion(internalProcessInstance.getProcessDefinitionVersion()); <START> <END> if(internalProcessInstance.getSuperExecutionId()!=null && ExecutionEntity.class.isInstance(internalProcessInstance)) { ExecutionEntity executionEntity = ExecutionEntity.class.cast(internalProcessInstance); if (Context.getCommandContext()==null) { ProcessEngineConfigurationImpl impl = (ProcessEngineConfigurationImpl) ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration(); impl.getCommandExecutor().execute(new Command<Void> () { @Override public Void execute(CommandContext commandContext) { Optional.ofNullable(executionEntity.getSuperExecution()) .ifPresent(superExecution -> processInstance.setParentId(superExecution.getProcessInstanceId())); return null; }}); } else { Optional.ofNullable(executionEntity.getSuperExecution()) .ifPresent(superExecution -> processInstance.setParentId(superExecution.getProcessInstanceId())); } } return processInstance; }</code><technical_language>a general problem for lazy loaded associations converters of Activiti engine transaction. This create N+1 additional queries database if need resolve child entities for record. able solve this implementing a query join entities in query database</technical_language>

Target:
public ProcessInstance from(org.activiti.engine.runtime.ProcessInstance internalProcessInstance) { ProcessInstanceImpl processInstance = new ProcessInstanceImpl(); processInstance.setId(internalProcessInstance.getId()); processInstance.setParentId(internalProcessInstance.getParentProcessInstanceId()); processInstance.setName(internalProcessInstance.getName()); processInstance.setDescription(internalProcessInstance.getDescription()); processInstance.setProcessDefinitionId(internalProcessInstance.getProcessDefinitionId()); processInstance.setProcessDefinitionKey(internalProcessInstance.getProcessDefinitionKey()); processInstance.setProcessDefinitionVersion(internalProcessInstance.getProcessDefinitionVersion()); processInstance.setInitiator(internalProcessInstance.getStartUserId()); processInstance.setStartDate(internalProcessInstance.getStartTime()); processInstance.setProcessDefinitionKey(internalProcessInstance.getProcessDefinitionKey()); processInstance.setBusinessKey(internalProcessInstance.getBusinessKey()); processInstance.setStatus(calculateStatus(internalProcessInstance)); processInstance.setProcessDefinitionVersion(internalProcessInstance.getProcessDefinitionVersion()); return processInstance; }