code: public final void cancelOld(
              final long starttimeThreshold, final long checkTimeThreshold, final String message) {
          final CriteriaBuilder builder = getSession().getCriteriaBuilder();
          final CriteriaUpdate<PrintJobStatusExtImpl> update =
                  builder.createCriteriaUpdate(PrintJobStatusExtImpl.class);
          final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class);
          update.where(builder.and(
                  builder.equal(root.get("status"), PrintJobStatus.Status.WAITING),
                  builder.or(
                          builder.lessThan(root.get("entry").get("startTime"), starttimeThreshold),
                          builder.and(builder.isNotNull(root.get("lastCheckTime")),
                                      builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold))
                  )
          ));
          update.set(root.get("status"), PrintJobStatus.Status.CANCELLED);
          update.set(root.get("error"), message);
          getSession().createQuery(update).executeUpdate();
      }
docs: Cancel old waiting jobs.
  
  @param starttimeThreshold threshold for start time
  @param checkTimeThreshold threshold for last check time
  @param message the error message