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 272ded55be..afd3b0500e 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 @@ -467,9 +467,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()); + } } } }