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

@param stackId
         stack id stack with major version (like HDP-2.2)
@param type
         the repository type

@return null if there is no suitable repository version
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java