@Transactional
  public void removeByDefinitionId(long definitionId) {
    EntityManager entityManager = m_entityManagerProvider.get();
    TypedQuery<AlertCurrentEntity> currentQuery = entityManager.createNamedQuery(
        "AlertCurrentEntity.removeByDefinitionId", AlertCurrentEntity.class);

    currentQuery.setParameter("definitionId", definitionId);
    currentQuery.executeUpdate();

    TypedQuery<AlertHistoryEntity> historyQuery = entityManager.createNamedQuery(
        "AlertHistoryEntity.removeByDefinitionId", AlertHistoryEntity.class);

    historyQuery.setParameter("definitionId", definitionId);
    historyQuery.executeUpdate();

    entityManager.clear();

    // if caching is enabled, invalidate the cache to force the latest values
    // back from the DB
    if (m_configuration.isAlertCacheEnabled()) {
      m_currentAlertCache.invalidateAll();
    }
  }
Removes alert history and current alerts for the specified alert defintiion
ID. This will invoke {@link EntityManager#clear()} when completed since the
JPQL statement will remove entries without going through the EM.

@param definitionId
         the ID of the definition to remove.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java