@RequiresSession
  public RepositoryVersionEntity findByStackNameAndVersion(String stackName, String version) {
    // TODO, need to make a unique composite key in DB using the repo_version's stack_id and version.
    // Ideally, 1.0-1234 foo should be unique in all HDP stacks.
    // The composite key is slightly more relaxed since it would only prevent 2.3.0-1234 multiple times in the HDP 2.3 stack.
    // There's already business logic to prevent creating 2.3-1234 in the wrong stack such as HDP 2.2.
    final TypedQuery<RepositoryVersionEntity> query = entityManagerProvider.get().createNamedQuery("repositoryVersionByStackNameAndVersion", RepositoryVersionEntity.class);
    query.setParameter("stackName", stackName);
    query.setParameter("version", version);
    return daoUtils.selectSingle(query);
  }
Retrieves repository version, which is unique in this stack.

@param stackName Stack name such as HDP, HDPWIN, BIGTOP
@param version version
@return null if there is no suitable repository version
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAO.java