docs: public JobExecution updateJobExecutionAndInstanceFinalStatus(PersistenceServiceUnit psu,
                                                                   final long jobExecutionId,
                                                                   final BatchStatus finalBatchStatus,
                                                                   final String finalExitStatus,
                                                                   final Date endTime) throws NoSuchJobExecutionException {
          EntityManager em = psu.createEntityManager();
          try {
              return new TranRequest<JobExecution>(em) {
                  @Override
                  public JobExecution call() {
                      JobExecutionEntity exec = entityMgr.find(JobExecutionEntity.class, jobExecutionId);
                      if (exec == null) {
                          throw new NoSuchJobExecutionException("No job execution found for id = " + jobExecutionId);
                      }
  
                      try {
                          verifyStatusTransitionIsValid(exec, finalBatchStatus);
  
                          exec.setBatchStatus(finalBatchStatus);
                          exec.getJobInstance().setBatchStatus(finalBatchStatus);
                          exec.setExitStatus(finalExitStatus);
                          exec.getJobInstance().setExitStatus(finalExitStatus);
                          exec.getJobInstance().setLastUpdatedTime(endTime);
                          // set the state to be the same value as the batchstatus
                          // Note: we only want to do this is if the batchStatus is one of the "done" statuses.
                          if (isFinalBatchStatus(finalBatchStatus)) {
                              InstanceState newInstanceState = InstanceState.valueOf(finalBatchStatus.toString());
                              verifyStateTransitionIsValid(exec.getJobInstance(), newInstanceState);
                              exec.getJobInstance().setInstanceState(newInstanceState);
                          }
                          exec.setLastUpdatedTime(endTime);
                          exec.setEndTime(endTime);
                          return exec;
                      } catch (BatchIllegalJobStatusTransitionException e) {
                          throw new PersistenceException(e);
                      }
  
                  }
              }.runInNewOrExistingGlobalTran();
          } finally {
              em.close();
          }
      }