public List<StageEntityPK> findRequestAndStageIdsInClusterBeforeDate(Long clusterId, long  beforeDateMillis) {
    EntityManager entityManager = entityManagerProvider.get();
    TypedQuery<StageEntityPK> requestQuery =
            entityManager.createNamedQuery("RequestEntity.findRequestStageIdsInClusterBeforeDate", StageEntityPK.class);

    requestQuery.setParameter("clusterId", clusterId);
    requestQuery.setParameter("beforeDate", beforeDateMillis);

    return daoUtils.selectList(requestQuery);
  }
Search for all request and stage ids in Request and Stage tables
@return the list of request/stage ids
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RequestDAO.java