@Override
 public long getNumberOfChildInstancesOfProcessInstance(final long processInstanceId)
     throws SProcessInstanceReadException {
   try {
     return persistenceRead.selectOne(
         SelectDescriptorBuilder.getNumberOfChildInstancesOfProcessInstance(processInstanceId));
   } catch (final SBonitaReadException e) {
     throw new SProcessInstanceReadException(e);
   }
 }
 @Override
 public SProcessInstance getProcessInstance(final long processInstanceId)
     throws SProcessInstanceReadException, SProcessInstanceNotFoundException {
   final SProcessInstance instance;
   try {
     instance =
         persistenceRead.selectById(
             SelectDescriptorBuilder.getElementById(
                 SProcessInstance.class, "ProcessInstance", processInstanceId));
   } catch (final SBonitaReadException sbre) {
     throw new SProcessInstanceReadException(sbre);
   }
   if (instance == null) {
     throw new SProcessInstanceNotFoundException(processInstanceId);
   }
   return instance;
 }
 @Override
 public List<Long> getChildInstanceIdsOfProcessInstance(
     final long processInstanceId,
     final int fromIndex,
     final int maxResults,
     final String sortingField,
     final OrderByType sortingOrder)
     throws SProcessInstanceReadException {
   try {
     final QueryOptions queryOptions =
         new QueryOptions(
             fromIndex, maxResults, SProcessInstance.class, sortingField, sortingOrder);
     final SelectListDescriptor<Long> elements =
         SelectDescriptorBuilder.getChildInstanceIdsOfProcessInstance(
             SProcessInstance.class, processInstanceId, queryOptions);
     return persistenceRead.selectList(elements);
   } catch (final SBonitaReadException e) {
     throw new SProcessInstanceReadException(e);
   }
 }
 @Override
 public List<Long> getSourceProcesInstanceIdsOfArchProcessInstancesFromDefinition(
     final long processDefinitionId,
     final int fromIndex,
     final int maxResults,
     final OrderByType sortingOrder)
     throws SProcessInstanceReadException {
   final ReadPersistenceService persistenceService =
       archiveService.getDefinitiveArchiveReadPersistenceService();
   final String saCommentSourceObjectId =
       BuilderFactory.get(SACommentBuilderFactory.class).getSourceObjectId();
   final QueryOptions queryOptions =
       new QueryOptions(
           fromIndex, maxResults, SAProcessInstance.class, saCommentSourceObjectId, sortingOrder);
   try {
     return persistenceService.selectList(
         SelectDescriptorBuilder.getSourceProcesInstanceIdsOfArchProcessInstancesFromDefinition(
             processDefinitionId, queryOptions));
   } catch (final SBonitaReadException e) {
     throw new SProcessInstanceReadException(e);
   }
 }