public function delete() {
        if (!$this->isPersistent()) throw new IllegalStateException('Cannot delete non-persistent '.get_class($this));

        $this->dao()->transaction(function() {
            if ($this->beforeDelete() !== true)                             // pre-processing hook
                return $this;

            if ($this->doDelete()) {                                        // perform deletion
                // reset identity property
                $idName = $this->dao()->getMapping()['identity']['name'];
                $this->$idName = null;

                $this->afterDelete();                                       // post-processing hook
            }
        });
        return $this;
    }