diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java index d0317be91d..1aaf69ef75 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java @@ -460,9 +460,13 @@ public void processDelete(AtlasVertex vertex) throws AtlasBaseException { AtlasVertex stakeholderTitleVertex = entityRetriever.getEntityVertex(stakeholderTitle.getGuid()); AtlasGraphUtilsV2.removeItemFromListPropertyValue(stakeholderTitleVertex, ATTR_DOMAIN_QUALIFIED_NAMES, vertex.getProperty(QUALIFIED_NAME, String.class)); List domainQualifiedNames = stakeholderTitleVertex.getMultiValuedProperty(ATTR_DOMAIN_QUALIFIED_NAMES, String.class); + if (CollectionUtils.isEmpty(domainQualifiedNames)) { - entityStore.deleteById(stakeholderTitle.getGuid()); - LOG.info("Deleted Stakeholder Title: {}", stakeholderTitle.getGuid()); + Iterator stakeholders = getActiveChildrenVertices(stakeholderTitleVertex, STAKEHOLDER_TITLE_EDGE_LABEL); + if (!stakeholders.hasNext()) { + entityStore.deleteById(stakeholderTitle.getGuid()); + LOG.info("Deleted Stakeholder Title: {}", stakeholderTitle.getGuid()); + } } } }