Delete related models. Rollback transaction and throw RelationException, if error occurred while deleting.
188625
public function afterDelete()
    {
        foreach ($this->relationalFields as $attribute => $value) {
            $getter = 'get' . ucfirst($attribute);
            /** @var ActiveQuery $activeQuery */
            $activeQuery = $this->owner->$getter();

            $models = [];
            if (empty($activeQuery->via)) {
                $models = $activeQuery->all();
            } else {
                if ($activeQuery->via instanceof ActiveQueryInterface) { // viaTable

                    $junctionTable = $activeQuery->via->from[0];
                    list($junctionColumn) = array_keys($activeQuery->via->link);
                    list($relatedColumn) = array_values($activeQuery->link);

                    $rows = (new Query())
                        ->from($junctionTable)
                        ->select([
                            $junctionColumn,
                            $relatedColumn
                        ])
                        ->where([
                            $junctionColumn => $this->owner->getPrimaryKey(),
                        ])->all();

                    $this->relationsMap($rows, function($row) use ($junctionTable) {
                        Yii::$app->db->createCommand()
                            ->delete($junctionTable, $row)
                            ->execute();
                    });

                } else { // via
                    $junctionGetter = 'get' . ucfirst($activeQuery->via[0]);
                    $models = $this->owner->$junctionGetter()->all();
                }
            }

            foreach ($models as $model) {
                if (!$model->delete()) {
                    Yii::$app->getDb()->getTransaction()->rollBack();
                    throw new RelationException('Model ' . $model::className() . ' not deleted due to unknown error');
                }
            }
        }
    }
538544
def rollback(using=None, sid=None):
    
    if sid:
        django.db.transaction.savepoint_rollback(sid)
    else:
        try:
             django.db.transaction.rollback(using)
        except django.db.transaction.TransactionManagementError:
             django.db.transaction.set_rollback(True, using)
256421
def delete_instance(model, instance_id, _commit=True):
    
    try:
        model = get_model(model)
    except ImportError:
        return

    instance = model.query.get(instance_id)
    if not instance:
        return

    db.session.delete(instance)
    try:
        if _commit:
            db.session.commit()
        else:
            db.session.flush()
    except Exception as exception:
        db.session.rollback()
        raise exception
724544
@Override
    public void rollback() throws DataCorruptedException, IOException, IllegalStateException{
        try {
            tranManager.rollback(t1);
        } catch (Exception e) {
            throw new DataCorruptedException("Error trying to rollback a Transaction.", e);
        }
    }
133532
public function rollbackTransaction()
    {
        if (!self::$transaction) {
            throw new TransactionException("There is no Active Transaction");
        }

        self::$transaction = false;
        foreach (self::$connectionList as $dbDriver) {
            $dbDriver->rollbackTransaction();
        }
    }
245934
public void rollback() throws DBException
    {
        super.rollback(); // Will throw an error if something is not set up right.
        try   {
            if (m_JDBCConnection != null)
                m_JDBCConnection.rollback();
        } catch (SQLException ex) {
            throw this.convertError(ex);
        }
    }
1126182
private function deleteManyToManyRelationIntermediateRecords(
        \Tx_Oelib_Model $model
    ) {
        foreach (array_keys($this->relations) as $key) {
            if ($this->isManyToManyRelationConfigured($key)) {
                $relationConfiguration =
                    $this->getRelationConfigurationFromTca($key);
                $mnTable = $relationConfiguration['MM'];

                if (isset($relationConfiguration['MM_opposite_field'])) {
                    $where = 'uid_foreign=' . $model->getUid();
                } else {
                    $where = 'uid_local=' . $model->getUid();
                }
                \Tx_Oelib_Db::delete($mnTable, $where);
            }
        }
    }
1224663
def delete(self):
        
        del_query = self._clone()

        # The delete is actually 2 queries - one to find related objects,
        # and one to delete. Make sure that the discovery of related
        # objects is performed on the same database as the deletion.
        del_query._clear_ordering()
        connection = self.model._meta.dj_connection

        connection.connection.delete_by_query(indices=connection.database, doc_types=self.model._meta.db_table,
                                              query=del_query._build_query())
        connection.connection.indices.refresh(indices=connection.database)
        # Clear the result cache, in case this QuerySet gets reused.
        self._result_cache = None
360652
public void rollback() throws HibernateException {
		Transaction tr = (Transaction) SessionFactoryHolder.getTransaction();
		if (tr != null) {
			tr.rollback();
		}
		SessionFactoryHolder.setTransaction(null);
	}
447770
public void rollback() throws HandlerException {
        if (_isInitiator) {
            try {
                _userTx.rollback();
            } catch (SystemException se) {
                throw CommonKnowledgeMessages.MESSAGES.userTransactionRollbackFailed(se);
            }
        } else if (_userTx != null) {
            try {
                _userTx.setRollbackOnly();
            } catch (SystemException se) {
                throw CommonKnowledgeMessages.MESSAGES.userTransactionSetRollbackOnlyFailed(se);
            }
        }
    }
492102
function() {
			Backbone.Relational.store.getCollection( this.instance )
				.unbind( 'relational:remove', this._modelRemovedFromCollection );
			
			Backbone.Relational.store.getCollection( this.relatedModel )
				.unbind( 'relational:add', this._relatedModelAdded )
				.unbind( 'relational:remove', this._relatedModelRemoved );
			
			_.each( this.getReverseRelations(), function( relation ) {
					relation.removeRelated( this.instance );
				}, this );
		}
706038
@Override
	public void rollback() throws TransactionManagementException {
		logger.entering(CLASSNAME, "rollback");
		try {
			if (userTran.getStatus() != Status.STATUS_NO_TRANSACTION) {
				userTran.rollback();
			}
			logger.log(Level.FINE, "javax.transaction.Status: {0}", userTran.getStatus());
		} catch (IllegalStateException e) {
			throw new TransactionManagementException(e);
		} catch (SecurityException e) {
			throw new TransactionManagementException(e);
		} catch (SystemException e) {
			throw new TransactionManagementException(e);
		}
		logger.exiting(CLASSNAME, "rollback");
	}
1022714
public function delete()
    {
        if (is_null($this->getKeyName())) {
            throw new Exception('No primary key defined on model.');
        }

        // If the model doesn't exist, there is nothing to delete so we'll just return
        // immediately and not do anything else. Otherwise, we will continue with a
        // deletion process on the model, firing the proper events, and so forth.
        if (!$this->exists) {
            return;
        }

        if ($this->fireModelEvent('deleting') === false) {
            return false;
        }

        // Here, we'll touch the owning models, verifying these timestamps get updated
        // for the models. This will allow any caching to get broken on the parents
        // by the timestamp. Then we will go ahead and delete the model instance.
        $this->touchOwners();

        $this->performDeleteOnModel();

        $this->exists = false;

        // Once the model has been deleted, we will fire off the deleted event so that
        // the developers may hook into post-delete operations. We will then return
        // a boolean true as the delete is presumably successful on the database.
        $this->fireModelEvent('deleted', false);

        return true;
    }
943087
def rollback(self, transaction = None):
        """"""
        if not self.in_transaction:
            raise NotInTransaction
        for collection, store in self.stores.items():
            store.rollback()
            indexes = self.indexes[collection]
            indexes_to_rebuild = []
            for key, index in indexes.items():
                try:
                    index.rollback()
                except NotInTransaction:
                    # this index is "dirty" and needs to be rebuilt
                    # (probably it has been created within a transaction)
                    indexes_to_rebuild.append(key)
            if indexes_to_rebuild:
                self.rebuild_indexes(collection, indexes_to_rebuild)
        self.in_transaction = False
904385
def clear_relation(cls):
        
        for k, v in cls.properties.items():
            if isinstance(v, ReferenceProperty):
                if hasattr(v, 'collection_name') and hasattr(v.reference_class, v.collection_name):
                    delattr(v.reference_class, v.collection_name)

                    if isinstance(v, OneToOne):
                        #append to reference_class._onetoone
                        del v.reference_class._onetoone[v.collection_name]
1133799
async def destroy_relation(self, local_relation, remote_relation):
        
        if ':' not in local_relation:
            local_relation = '{}:{}'.format(self.name, local_relation)

        app_facade = client.ApplicationFacade.from_connection(self.connection)

        log.debug(
            'Destroying relation %s <-> %s', local_relation, remote_relation)

        return await app_facade.DestroyRelation([
            local_relation, remote_relation])
1186126
public function delete()
    {
        if ($this->isNewRecord()) {
            throw new DeleteModelException("New models can't be deleted.");
        }

        $this->beforeDelete();
        $this->raiseEvent("BeforeDelete");

        $this->Deleted = true;
        $this->save();

        $this->afterDelete();
        $this->raiseEvent("AfterDelete");
    }