Source:
<code>public void applyLatestConfigurations(StackId stackId) { clusterGlobalLock.writeLock().lock(); try { ClusterEntity clusterEntity = getClusterEntity(); Collection<ClusterConfigEntity> configEntities = clusterEntity.getClusterConfigEntities(); ImmutableMap<Object, ClusterConfigEntity> clusterConfigEntityMap = Maps.uniqueIndex( configEntities, Functions.identity()); for (ClusterConfigEntity clusterConfig : configEntities) { if (clusterConfig.isSelected()) { clusterConfig.setSelected(false); LOG.debug("Disabling configuration with tag {}", clusterConfig.getType(), clusterConfig.getTag()); } } Collection<ClusterConfigEntity> latestConfigMappingByStack = clusterDAO.getLatestConfigurations( clusterEntity.getClusterId(), stackId); Set<String> configTypesUpdated = new HashSet<>(); for (ClusterConfigEntity clusterConfig : latestConfigMappingByStack) { clusterConfig = clusterConfigEntityMap.get(clusterConfig); clusterConfig.setSelected(true); configTypesUpdated.add(clusterConfig.getType()); LOG.info("Setting with version tag created on to selected for stack {}", clusterConfig.getType(), clusterConfig.getTag(), new Date(clusterConfig.getTimestamp()), stackId); } <START> for (ClusterConfigEntity clusterConfig : configEntities) { <END> clusterDAO.merge(clusterConfig, true); } cacheConfigurations(); LOG.info( "Applied latest configurations for stack {}. The the following types were modified: {}", stackId, StringUtils.join(configTypesUpdated, ',')); } finally { clusterGlobalLock.writeLock().unlock(); } EntityManagerCacheInvalidationEvent event = new EntityManagerCacheInvalidationEvent(); jpaEventPublisher.publish(event); }</code><technical_language>this structure multiple times, create clusterDAO.merge(List<ClusterConfigEntity> entities, boolean flush)</technical_language>

Target:
public void applyLatestConfigurations(StackId stackId) { clusterGlobalLock.writeLock().lock(); try { ClusterEntity clusterEntity = getClusterEntity(); Collection<ClusterConfigEntity> configEntities = clusterEntity.getClusterConfigEntities(); ImmutableMap<Object, ClusterConfigEntity> clusterConfigEntityMap = Maps.uniqueIndex( configEntities, Functions.identity()); for (ClusterConfigEntity clusterConfig : configEntities) { if (clusterConfig.isSelected()) { clusterConfig.setSelected(false); LOG.debug("Disabling configuration with tag {}", clusterConfig.getType(), clusterConfig.getTag()); } } Collection<ClusterConfigEntity> latestConfigMappingByStack = clusterDAO.getLatestConfigurations( clusterEntity.getClusterId(), stackId); Set<String> configTypesUpdated = new HashSet<>(); for (ClusterConfigEntity clusterConfig : latestConfigMappingByStack) { clusterConfig = clusterConfigEntityMap.get(clusterConfig); clusterConfig.setSelected(true); configTypesUpdated.add(clusterConfig.getType()); LOG.info("Setting with version tag created on to selected for stack {}", clusterConfig.getType(), clusterConfig.getTag(), new Date(clusterConfig.getTimestamp()), stackId); } clusterDAO.merge(configEntities, true); cacheConfigurations(); LOG.info( "Applied latest configurations for stack {}. The the following types were modified: {}", stackId, StringUtils.join(configTypesUpdated, ',')); } finally { clusterGlobalLock.writeLock().unlock(); } EntityManagerCacheInvalidationEvent event = new EntityManagerCacheInvalidationEvent(); jpaEventPublisher.publish(event); }