@RequiresSession
  public UpgradeItemEntity findUpgradeItemByRequestAndStage(Long requestId, Long stageId) {
    TypedQuery<UpgradeItemEntity> query = entityManagerProvider.get().createQuery(
        "SELECT p FROM UpgradeItemEntity p WHERE p.stageId = :stageId AND p.upgradeGroupEntity.upgradeEntity.requestId = :requestId",
        UpgradeItemEntity.class);
    query.setParameter("requestId", requestId);
    query.setParameter("stageId", stageId);

    return daoUtils.selectSingle(query);
  }
@param requestId the request id
@param stageId the stage id
@return the upgrade entity, or {@code null} if not found
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UpgradeDAO.java