public function addObject($object, $state, $repository)
    {
        $data = $repository->getHydrator()->unhydrate($object);
        $oid = spl_object_hash($object);
        $id = isset($data['_id']) ? serialize($data['_id']) . $repository->getCollection() : $oid;

        if (!isset($this->objectStates[$id])) {
            $this->objectStates[$id] = $state;
        }
        $this->objects[$id] = $object;
        $this->objectsRepository[$oid] = $repository;
    }