@Transactional
  public void removeAllByGroup(final Long groupId) {
    populateCache();

    TypedQuery<Long> query = entityManagerProvider.get().createQuery
      ("DELETE FROM ConfigGroupHostMappingEntity confighosts WHERE " +
        "confighosts.configGroupId = ?1", Long.class);

    daoUtils.executeUpdate(query, groupId);
    // Flush to current transaction required in order to avoid Eclipse link
    // from re-ordering delete
    entityManagerProvider.get().flush();

    for (Set<ConfigGroupHostMapping> setByHost : configGroupHostMappingByHost.values()) {

      CollectionUtils.filter(setByHost, new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
          return !((ConfigGroupHostMapping) arg0).getConfigGroupId().equals(groupId);
        }
      });
    }

  }
Return entity object which can be used for operations like remove
directly.
@param configGroupHostMappingEntityPK
@return
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ConfigGroupHostMappingDAO.java