@Transactional
  protected void saveEntitiesTransactional(List<AlertCurrentEntity> toMerge,
                    List<AlertCurrentEntity> toCreateHistoryAndMerge) {
    for (AlertCurrentEntity entity : toMerge) {
      merge(entity, m_configuration.isAlertCacheEnabled());
    }

    for (AlertCurrentEntity entity : toCreateHistoryAndMerge) {
      create(entity.getAlertHistory());
      merge(entity);

      if (LOG.isDebugEnabled()) {
        LOG.debug(
            "Alert State Merged: CurrentId {}, CurrentTimestamp {}, HistoryId {}, HistoryState {}",
            entity.getAlertId(), entity.getLatestTimestamp(),
            entity.getAlertHistory().getAlertId(),
            entity.getAlertHistory().getAlertState());
      }
    }
  }
Saves alert and alert history entities in single transaction
@param toMerge - merge alert only
@param toCreateHistoryAndMerge - create new history, merge alert
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java