code: private DbOperation hasOptimisticLockingException(List<DbOperation> operationsToFlush, Throwable cause) {
  
      BatchExecutorException batchExecutorException = ExceptionUtil.findBatchExecutorException(cause);
  
      if (batchExecutorException != null) {
  
        int failedOperationIndex = batchExecutorException.getSuccessfulBatchResults().size();
        if (failedOperationIndex < operationsToFlush.size()) {
          DbOperation failedOperation = operationsToFlush.get(failedOperationIndex);
          if (isOptimisticLockingException(failedOperation, cause)) {
            return failedOperation;
          }
        }
      }
  
      return null;
    }
docs: An OptimisticLockingException check for batch processing
  
  @param operationsToFlush The list of DB operations in which the Exception occurred
  @param cause the Exception object
  @return The DbOperation where the OptimisticLockingException has occurred
  or null if no OptimisticLockingException occurred