private int executeQuery(String namedQuery, Class entityType, long clusterId, long timestamp) {
    LOG.info("Starting: Delete/update entries older than [ {} ] for entity [{}]", timestamp, entityType);
    TypedQuery query = m_entityManagerProvider.get().createNamedQuery(namedQuery, entityType);

    query.setParameter("clusterId", clusterId);
    query.setParameter("beforeDate", timestamp);

    int affectedRows = query.executeUpdate();

    m_entityManagerProvider.get().flush();
    m_entityManagerProvider.get().clear();

    LOG.info("Completed: Delete/update entries older than [ {} ] for entity: [{}]. Number of entities deleted: [{}]",
        timestamp, entityType, affectedRows);

    return affectedRows;
  }
Utility method for executing update or delete named queries having as input parameters the cluster id and a timestamp.

@param namedQuery the named query to be executed
@param entityType the type of the entity
@param clusterId  the cluster identifier
@param timestamp  timestamp
@return the number of rows affected by the query execution.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java