@Transactional
  public void removeHostFromServiceConfigs(final Long hostId) {
    List<ServiceConfigEntity> allServiceConfigs = findAll();
    for (ServiceConfigEntity serviceConfigEntity : allServiceConfigs) {
      List<Long> hostIds = serviceConfigEntity.getHostIds();
      if (hostIds != null && hostIds.contains(hostId)) {
        // Remove the hostId
        CollectionUtils.filter(hostIds, new Predicate() {
          @Override
          public boolean evaluate(Object arg0) {
            return !((Long) arg0).equals(hostId);
          }
        });
        serviceConfigEntity.setHostIds(hostIds);
      }
    }
  }
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