@RequiresSession
  public ClusterConfigEntity findEnabledConfigByType(long clusterId, String type) {

    TypedQuery<ClusterConfigEntity> query = entityManagerProvider.get().createNamedQuery(
        "ClusterConfigEntity.findEnabledConfigByType", ClusterConfigEntity.class);

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

    return daoUtils.selectOne(query);
  }
Gets the latest config in the given cluster by type name. Only a config
which is enabled can be returned.

@param clusterId
         the ID of the cluster.
@param type
         the config type (not {@code null}).
@return a config, or {@code null} if there is none enabled.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java