@Transactional
  public List<AlertNoticeEntity> createNotices(List<AlertNoticeEntity> entities) {
    if (null == entities || entities.isEmpty()) {
      return entities;
    }

    List<AlertNoticeEntity> managedEntities = new ArrayList<>(entities.size());
    for (AlertNoticeEntity entity : entities) {
      AlertNoticeEntity managedEntity = merge(entity);
      managedEntities.add(managedEntity);
    }

    return managedEntities;
  }
Creates new alert notices using the {@link EntityManager#merge(Object)}
method to ensure that the associated {@link AlertTargetEntity} instances
are also updated.
<p/>
The method returns the newly managed entities as the ones passed in will
not be managed.

@param entities
         the targets to create (not {@code null}).
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java