@RequiresSession
  public List<HostVersionEntity> findByClusterStackAndVersion(
      String clusterName, StackId stackId, String version) {
    final TypedQuery<HostVersionEntity> query = entityManagerProvider.get().createNamedQuery("hostVersionByClusterAndStackAndVersion", HostVersionEntity.class);
    query.setParameter("clusterName", clusterName);
    query.setParameter("stackName", stackId.getStackName());
    query.setParameter("stackVersion", stackId.getStackVersion());
    query.setParameter("version", version);

    return daoUtils.selectList(query);
  }
Retrieve all of the host versions for the given cluster name, stack name,
and stack version.

@param clusterName
         Cluster name
@param stackId
         Stack (e.g., HDP-2.2)
@param version
         Stack version (e.g., 2.2.0.1-995)
@return Return all of the host versions that match the criteria.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostVersionDAO.java