code: private <T, Y extends Number> TypedQuery<T> createTypedQuery(
              Class<T> entityCls, SingularAttribute<T, Y> attribute,
              SqlComparator comparator, Y value) {
          EntityManager entityManager = this.entityManagerProvider.get();
          CriteriaBuilder builder = entityManager.getCriteriaBuilder();
          CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls);
          Root<T> root = criteriaQuery.from(entityCls);
          Path<Y> path = root.get(attribute);
          Predicate pred;
          switch (comparator) {
              case LESS_THAN:
                  pred = builder.lt(path, value);
                  break;
              case LESS_THAN_OR_EQUAL_TO:
                  pred = builder.le(path, value);
                  break;
              case EQUAL_TO:
                  pred = builder.equal(path, value);
                  break;
              case NOT_EQUAL_TO:
                  pred = builder.notEqual(path, value);
                  break;
              case GREATER_THAN_OR_EQUAL_TO:
                  pred = builder.ge(path, value);
                  break;
              case GREATER_THAN:
                  pred = builder.gt(path, value);
                  break;
              default:
                  throw new AssertionError("Invalid SQLComparator: "
                          + comparator);
          }
          return entityManager.createQuery(criteriaQuery.where(pred));
      }
docs: Creates a typed query for entities with the given numerical attribute
  value.
  
  @param <T> the type of the entity to return.
  @param <Y> the type of the attribute.
  @param entityCls the entity's class.
  @param attribute the attribute.
  @param comparator the comparator.
  @param value the value or value threshold.
  @return a typed query with the given criteria.