public function save()
    {
        $this->checkDB();
        $transaction = new SwatDBTransaction($this->db);
        try {
            foreach ($this->removed_objects as $object) {
                $object->setDatabase($this->db);
                $object->delete();
            }

            foreach ($this->objects as $object) {
                $object->setDatabase($this->db);
                $object->save();
            }

            $transaction->commit();
        } catch (Exception $e) {
            $transaction->rollback();
            throw $e;
        }

        $this->removed_objects = array();
        $this->reindex();
    }