final public function save($forceSaveRegardlessOfState = false)
    {
        try {
            $this->isConsistent();
        } catch (ModelConsistencyValidationException $er) {
            // If the model isn't consistent we don't let it get into the database.
            throw $er;
        }

        if (!$forceSaveRegardlessOfState && !$this->isNewRecord() && !$this->hasChanged()) {
            return $this->uniqueIdentifier;
        }

        $this->beforeSave();
        $this->raiseEvent("BeforeSave");

        $repository = $this->getRepository();
        $repository->saveObject($this);

        $this->newRecord = false;

        $this->callAfterSaveCallbacks();

        $this->afterSave();
        $this->raiseEvent("AfterSave");

        $this->takeChangeSnapshot();

        return $this->uniqueIdentifier;
    }