@RequiresSession
  public Long findNextServiceConfigVersion(long clusterId, String serviceName) {
    TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery(
        "ServiceConfigEntity.findNextServiceConfigVersion", Number.class);

    query.setParameter("clusterId", clusterId);
    query.setParameter("serviceName", serviceName);

    return daoUtils.selectSingle(query).longValue();
  }
Gets the next version that will be created when persisting a new
{@link ServiceConfigEntity}.

@param clusterId
         the cluster that the service is a part of.
@param serviceName
         the name of the service (not {@code null}).
@return the maximum version value + 1
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java