docs: @Override
      public List<TaskStatus<?>> findTaskStatus(String pattern, Character escape, TaskState state, boolean inState,
                                                Long minId, Integer maxResults, String owner, boolean includeTrigger,
                                                PersistentExecutor executor) throws Exception {
          StringBuilder find = new StringBuilder(187)
                          .append("SELECT t.ID,t.LOADER,t.MBITS,t.INAME,t.NEXTEXEC,t.RESLT,t.STATES");
          if (includeTrigger)
              find.append(",t.TRIG");
          find.append(" FROM Task t");
          int i = 0;
          if (minId != null)
              find.append(++i == 1 ? " WHERE" : " AND").append(" t.ID>=:m");
          if (owner != null)
              find.append(++i == 1 ? " WHERE" : " AND").append(" t.OWNR=:o");
          if (pattern != null) {
              find.append(++i == 1 ? " WHERE" : " AND").append(" t.INAME LIKE :p");
              if (escape != null)
                  find.append(" ESCAPE :e");
          }
          Map<String, Object> stateParams = null;
          if (!TaskState.ANY.equals(state))
              stateParams = appendStateComparison(find.append(++i == 1 ? " WHERE " : " AND "), state, inState);
          else if (!inState)
              return Collections.emptyList(); // empty result if someone asks for tasks not in any state
          find.append(" ORDER BY t.ID ASC");
  
          final boolean trace = TraceComponent.isAnyTracingEnabled();
          if (trace && tc.isEntryEnabled())
              Tr.entry(this, tc, "findTaskStatus", pattern, escape, state + ":" + inState, minId, maxResults, owner, executor, find);
  
          List<Object[]> results;
          EntityManager em = getPersistenceServiceUnit().createEntityManager();
          try {
              TypedQuery<Object[]> query = em.createQuery(find.toString(), Object[].class);
              if (maxResults != null)
                  query.setMaxResults(maxResults);
              if (minId != null)
                  query.setParameter("m", minId);
              if (owner != null)
                  query.setParameter("o", owner);
              if (pattern != null) {
                  query.setParameter("p", pattern);
                  if (escape != null)
                      query.setParameter("e", escape);
              }
              if (stateParams != null)
                  for (Map.Entry<String, Object> param : stateParams.entrySet())
                      query.setParameter(param.getKey(), param.getValue());
  
              results = query.getResultList();
          } finally {
              em.close();
          }
  
          List<TaskStatus<?>> statusList = new ArrayList<TaskStatus<?>>(results.size());
          for (Object[] result : results) {
              TaskRecord record = new TaskRecord(false);
              record.setId((Long) result[0]);
              record.setIdentifierOfClassLoader((String) result[1]);
              record.setMiscBinaryFlags((Short) result[2]);
              record.setName((String) result[3]);
              record.setNextExecutionTime((Long) result[4]);
              record.setResult((byte[]) result[5]);
              record.setState((Short) result[6]);
              if (includeTrigger)
                  record.setTrigger((byte[]) result[7]);
              statusList.add(record.toTaskStatus(executor));
          }
  
          if (trace && tc.isEntryEnabled())
              Tr.exit(this, tc, "findTaskStatus", statusList.size() < 20 ? statusList : statusList.size());
          return statusList;
      }