@RequiresSession
  public List<HostVersionEntity> findByRepositoryAndStates(RepositoryVersionEntity repositoryVersion,
      Collection<RepositoryVersionState> states) {

    TypedQuery<HostVersionEntity> query = entityManagerProvider.get().createNamedQuery(
        "hostVersionByRepositoryAndStates", HostVersionEntity.class);

    query.setParameter("repositoryVersion", repositoryVersion);
    query.setParameter("states", states);

    return daoUtils.selectList(query);
  }
Gets all host version entities that are of the given states

@param repositoryVersion
         the repository (not {@code null})
@param states
         the states
@return the host versions
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostVersionDAO.java