public function save() {
        if (!$this->isPersistent()) {
            $this->dao()->transaction(function() {
                if ($this->beforeSave() !== true)               // pre-processing hook
                    return $this;
                $this->insert();
                $this->afterSave();                             // post-processing hook
            });
        }
        elseif ($this->isModified()) {
            $this->dao()->transaction(function() {
                if ($this->beforeSave() !== true)               // pre-processing hook
                    return $this;
                $this->update();
                $this->afterSave();                             // post-processing hook
            });
        }
        else {
            // persistent but not modified
        }
        return $this;
    }