docs: @Override
      public int remove(String pattern, Character escape, TaskState state, boolean inState, String owner) throws Exception {
          StringBuilder delete = new StringBuilder(100)
                          .append("DELETE FROM Task t");
          int i = 0;
          if (owner != null)
              delete.append(++i == 1 ? " WHERE" : " AND").append(" t.OWNR=:o");
          if (pattern != null) {
              delete.append(++i == 1 ? " WHERE" : " AND").append(" t.INAME LIKE :p");
              if (escape != null)
                  delete.append(" ESCAPE :e");
          }
          Map<String, Object> stateParams = null;
          if (!TaskState.ANY.equals(state))
              stateParams = appendStateComparison(delete.append(++i == 1 ? " WHERE " : " AND "), state, inState);
          else if (!inState)
              return 0; // empty result if someone asks to remove tasks not in any state
  
          final boolean trace = TraceComponent.isAnyTracingEnabled();
          if (trace && tc.isEntryEnabled())
              Tr.entry(this, tc, "remove", pattern, escape, state + ":" + inState, owner, delete);
  
          EntityManager em = getPersistenceServiceUnit().createEntityManager();
          try {
              Query query = em.createQuery(delete.toString());
              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());
  
              int count = query.executeUpdate();
  
              if (trace && tc.isEntryEnabled())
                  Tr.exit(this, tc, "remove", count);
              return count;
          } finally {
              em.close();
          }
      }