protected function buildEntity(array $attributes)
    {
        $wrapper = $this->getWrapperInstance();

        // Hydrate any embedded Value Object
        //
        // TODO Move this to the result builder instead,
        // as we'll handle this the same way as they were
        // eager loaded relationships.
        $this->hydrateValueObjects($attributes);

        $wrapper->setEntityAttributes($attributes);

        $wrapper->setProxies();

        $entity = $wrapper->unwrap();

        // Once the object has been hydrated, we'll add
        // the instance to the instance cache.
        if ($this->entityMap->getKeyName() !== null) {
            $id = $this->getPrimaryKeyValue($attributes);
            $this->mapper->getInstanceCache()->add($entity, $id);
        }

        return $entity;
    }