getLinks method returns deleted Entities, how to prevent it?

xybrek :

Below is my code to get the list of Entity's linked. It works but the problem is that even the deleted Entity is returned, although the Entity is already emptied out and it is the only property set. Is there a way to not return the deleted entities at all? Or is there a way to filter it out?

EntityId idOfEntity = txn.toEntityId(entityId);
Entity txnEntity = txn.getEntity(idOfEntity);
EntityIterable result = txnEntity.getLinks(Arrays.asList(new String[] {linkName}));
for (Entity entity : result) {
}
Vyacheslav Lukianov :

When you delete an entity, it's your responsibility to check if there are incoming links to the deleted entity. Otherwise so called "phantom links" can appear. You can set -Dexodus.entityStore.debug.searchForIncomingLinksOnDelete=true (PersistentEntityStoreConfig#setDebugSearchForIncomingLinksOnDelete(true)) to debug deletion in your application. With this setting, Xodus searches for incoming links to each deleted entity and throws EntityStoreException if it finds. The setting should not be used in production environment as it significantly slows down entity deletion performance.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=107263&siteId=1