@Transactional
  protected void flushCachedEntitiesToJPATransactional() {

    // capture for logging purposes
    long cachedEntityCount = m_currentAlertCache.size();

    ConcurrentMap<AlertCacheKey, AlertCurrentEntity> map = m_currentAlertCache.asMap();
    Set<Entry<AlertCacheKey, AlertCurrentEntity>> entries = map.entrySet();
    for (Entry<AlertCacheKey, AlertCurrentEntity> entry : entries) {
      merge(entry.getValue());
    }

    m_currentAlertCache.invalidateAll();

    LOG.info("Flushed {} cached alerts to the database", cachedEntityCount);
  }
Writes all cached {@link AlertCurrentEntity} instances to the database and
clears the cache.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java