@RequiresSession
  public List<AlertNoticeEntity> findAllNotices(AlertNoticeRequest request) {
    EntityManager entityManager = entityManagerProvider.get();

    // convert the Ambari predicate into a JPA predicate
    NoticePredicateVisitor visitor = new NoticePredicateVisitor();
    PredicateHelper.visit(request.Predicate, visitor);

    CriteriaQuery<AlertNoticeEntity> query = visitor.getCriteriaQuery();
    jakarta.persistence.criteria.Predicate jpaPredicate = visitor.getJpaPredicate();

    if (null != jpaPredicate) {
      query.where(jpaPredicate);
    }

    // sorting
    JpaSortBuilder<AlertNoticeEntity> sortBuilder = new JpaSortBuilder<>();
    List<Order> sortOrders = sortBuilder.buildSortOrders(request.Sort, visitor);
    query.orderBy(sortOrders);

    // pagination
    TypedQuery<AlertNoticeEntity> typedQuery = entityManager.createQuery(query);
    if (null != request.Pagination) {
      typedQuery.setFirstResult(request.Pagination.getOffset());
      typedQuery.setMaxResults(request.Pagination.getPageSize());
    }

    return daoUtils.selectList(typedQuery);
  }
Gets all alert notifications stored in the database that match the given
predicate, pagination, and sorting.

@param request
@return all alert notifications or empty list if none exist (never
        {@code null}).
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java