@RequiresSession
  public List<RepositoryVersionEntity> findByStack(StackId stackId) {
    final TypedQuery<RepositoryVersionEntity> query = entityManagerProvider.get().createNamedQuery("repositoryVersionByStack", RepositoryVersionEntity.class);
    query.setParameter("stackName", stackId.getStackName());
    query.setParameter("stackVersion", stackId.getStackVersion());
    return daoUtils.selectList(query);
  }
Retrieves repository version by stack.

@param stackId stack id
         stack with major version (like HDP-2.2)
@return null if there is no suitable repository version
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java