if (hosts != null && !hosts.isEmpty()) {
for (Host host : hosts.values()) {
HostEntity hostEntity = hostDAO.findByName(host.getHostName());
if (hostEntity != null) {
ConfigGroupHostMappingEntity hostMappingEntity = new
ConfigGroupHostMappingEntity();
hostMappingEntity.setHostname(host.getHostName());
hostMappingEntity.setHostEntity(hostEntity);
hostMappingEntity.setConfigGroupEntity(configGroupEntity);
hostMappingEntity.setConfigGroupId(configGroupEntity.getGroupId());
configGroupHostMappingDAO.create(hostMappingEntity);
// TODO: Make sure this does not throw Nullpointer based on JPA docs
configGroupEntity.getConfigGroupHostMappingEntities().add
(hostMappingEntity);
configGroupDAO.merge(configGroupEntity);