Evict all entity instances referenced by this entity instance through a bidirectional relation.

@param entity the entity whose references need to be evicted
15364
private void evictBiDiReferencedEntities(Entity entity) {
    Stream<EntityKey> backreffingEntities =
        getEntityType()
            .getMappedByAttributes()
            .flatMap(mappedByAttr -> Streams.stream(entity.getEntities(mappedByAttr.getName())))
            .map(EntityKey::create);
    Stream<EntityKey> manyToOneEntities =
        getEntityType()
            .getInversedByAttributes()
            .map(inversedByAttr -> entity.getEntity(inversedByAttr.getName()))
            .filter(Objects::nonNull)
            .map(EntityKey::create);

    l1Cache.evict(Stream.concat(backreffingEntities, manyToOneEntities));
  }
478894
protected function deleteEntity($entity)
    {
        $this->checkEntityType($entity);

        $delete = new Delete($this->aggregate($entity), $this->newQueryBuilder());

        $delete->execute();
    }
421467
private void evictBiDiReferencedEntityTypes() {
    getEntityType().getMappedByAttributes().map(Attribute::getRefEntity).forEach(l1Cache::evictAll);
    getEntityType()
        .getInversedByAttributes()
        .map(Attribute::getRefEntity)
        .forEach(l1Cache::evictAll);
  }
1359596
public function remove($entity)
    {
        $objectManager = $this->getObjectManager();
        $objectManager->remove($entity);
        $objectManager->flush();
    }
872342
public function delete($entity)
    {
        $this->_em->remove($entity);
        $this->_em->flush($entity);
    }
1115769
public function remove($entity)
    {
        if ($this->evm->hasListeners(Events::preRemove)) {
            $this->evm->dispatchEvent(Events::preRemove, new Event\LifecycleEventArgs($entity, $this->sm));
        }

        $oid = spl_object_hash($entity);
        $this->scheduledForDelete[$oid] = $entity;

        if ($this->evm->hasListeners(Events::postRemove)) {
            $this->evm->dispatchEvent(Events::postRemove, new Event\LifecycleEventArgs($entity, $this->sm));
        }
    }
629516
def destroy_entitiy(self, entity):
        
        for relation in self._database.values():
            relation.pop(entity, None)
        for l in self._entities_by_component.values():
            l.discard(entity)
        self._entities.remove(entity)
854890
def delete_entity(sender, instance, **kwargs):
    """"""
    # 1 means that the last Data object is going to be deleted.
    Entity.objects.annotate(num_data=Count('data')).filter(data=instance, num_data=1).delete()
601131
protected function removeEntity (...$entities) : void
    {
        try
        {
            $entities = \array_filter($entities);

            if (empty($entities))
            {
                return;
            }

            $entityManager = $this->getEntityManager();
            \array_map([$entityManager, "remove"], $entities);
            $entityManager->flush();
        }
        catch (ForeignKeyConstraintViolationException $foreignKeyException)
        {
            throw new EntityRemovalBlockedException(
                $entities,
                "Can't remove entities as a foreign key constraint failed.",
                $foreignKeyException
            );
        }
    }
1143165
public function handle(Entity $entity): void
    {
        $this->trash = $entity->getEntityAttributeValueTrash();

        // Wrap the whole process inside database transaction
        $connection = $entity->getConnection();
        $connection->beginTransaction();

        try {
            foreach ($entity->getEntityAttributes() as $attribute) {
                if ($entity->relationLoaded($relation = $attribute->getAttribute('slug'))) {
                    $relationValue = $entity->getRelationValue($relation);

                    if ($relationValue instanceof ValueCollection) {
                        foreach ($relationValue as $value) {
                            // Set attribute value's entity_id since it's always null,
                            // because when RelationBuilder::build is called very early
                            $value->setAttribute('entity_id', $entity->getKey());
                            $this->saveOrTrashValue($value);
                        }
                    } elseif (! is_null($relationValue)) {
                        // Set attribute value's entity_id since it's always null,
                        // because when RelationBuilder::build is called very early
                        $relationValue->setAttribute('entity_id', $entity->getKey());
                        $this->saveOrTrashValue($relationValue);
                    }
                }
            }

            if ($this->trash->count()) {
                // Fetch the first item's class to know the model used for deletion
                $class = get_class($this->trash->first());

                // Let's batch delete all the values based on their ids
                $class::whereIn('id', $this->trash->pluck('id'))->delete();

                // Now, empty the trash
                $this->trash = collect([]);
            }
        } catch (Exception $e) {
            // Rollback transaction on failure
            $connection->rollBack();

            throw $e;
        }

        // Commit transaction on success
        $connection->commit();
    }
1365742
@Trivial
    protected synchronized void evictStaleEntries() {
/*
 * final String METHODNAME = "evictStaleEntries";
 * if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
 * int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size();
 * Tr.debug(tc, METHODNAME + " The current cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ")");
 * }
 */

        // log only when we evict the last table
        if (!tertiaryTable.isEmpty()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "evictStaleEntries Evicting tertiaryTable cache " + cacheName + ", size is " + tertiaryTable.size());
            }
        }
        tertiaryTable = secondaryTable;
        secondaryTable = primaryTable;
        primaryTable = new ConcurrentHashMap<String, Object>((minSize > secondaryTable.size()) ? minSize : secondaryTable.size());
    }
590499
public function removeEntity($entity)
    {
        $this->entityManager->remove($entity);
        $this->entityManager->flush();
        return true;
    }
227406
public function deleteAllRelations($entity)
    {
        $this->deleteNotes($entity);
        $this->deleteAddresses($entity);
        $this->deleteEmails($entity);
        $this->deleteFaxes($entity);
        $this->deleteSocialMediaProfiles($entity);
        $this->deletePhones($entity);
        $this->deleteUrls($entity);
    }
1309379
private void clearEntityAttributes(CmsEntity entity) {

        for (CmsEntityAttribute attribute : entity.getAttributes()) {
            if (attribute.isComplexValue()) {
                for (CmsEntity child : attribute.getComplexValues()) {
                    clearEntityAttributes(child);
                    removeEntity(child.getId());
                }
            }
            entity.removeAttributeSilent(attribute.getAttributeName());
        }
    }
1333997
public function addReferencesToEntity($entity)
    {
        foreach ($this->strategies as $strategy) {
            $strategy->addReferencesToEntity($entity);
        }

        $this->objectManager->flush();
    }
687750
public function detach($entity)
    {
        $this->entityRegistry->deregisterEntity($entity);
        $objectHashId = $this->entityRegistry->getObjectHashId($entity);
        unset($this->scheduledForInsertion[$objectHashId]);
        unset($this->scheduledForUpdate[$objectHashId]);
        unset($this->scheduledForDeletion[$objectHashId]);
    }
255220
private void evictEntry(Node node) {
    data.remove(node.key);
    node.remove();
    if (node.freq.isEmpty()) {
      node.freq.remove();
    }
  }