class HostConfigMappingDAO {

  @Transactional
  public void create(HostConfigMapping hostConfigMapping) {
    populateCache();
    
    //create in db
    entityManagerProvider.get().persist(buildHostConfigMappingEntity(hostConfigMapping));
    
    //create in cache
    Long hostId = hostConfigMapping.getHostId();

    if (hostId != null) {
      Set<HostConfigMapping> set;
      if (hostConfigMappingByHost.containsKey(hostId)) {
        set = hostConfigMappingByHost.get(hostId);
      } else {
        set = new HashSet<>();
        hostConfigMappingByHost.put(hostId, set);
      }

      set.add(hostConfigMapping);
    }
  }

}