List<Integer> resourceIdsInError = new ArrayList<Integer>();
Throwable firstThrowable = null;
// We want to copy the group level AlertDefinitions, so fetch them with the relevant lazy fields, so we
// have everything we need when calling the copy constructor, minimizing
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.addFilterResourceGroupIds(resourceGroupId);
criteria.fetchGroupAlertDefinition(false);
criteria.fetchConditions(true);
criteria.fetchAlertNotifications(true);
// Apply paging when optionally fetching collections, to avoid duplicates. Hibernate seems to apply DISTINCT,
// which is what we want. Use a huge # because we want them all.
criteria.setPaging(0, Integer.MAX_VALUE);
List<AlertDefinition> groupAlertDefinitions = alertDefinitionManager.findAlertDefinitionsByCriteria(subject,
criteria);
for (AlertDefinition groupAlertDefinition : groupAlertDefinitions) {