protected function flattenEmbeddables(array $attributes): array
    {
        // TODO : deprecate old implementation
        $embeddables = $this->entityMap->getEmbeddables();

        foreach ($embeddables as $localKey => $embed) {
            // Retrieve the value object from the entity's attributes
            $valueObject = $attributes[$localKey];

            // Unset the corresponding key
            unset($attributes[$localKey]);

            // TODO Make wrapper object compatible with value objects
            $valueObjectAttributes = $valueObject->getEntityAttributes();

            $voMap = $this->getMapper()->getManager()->getValueMap($embed);
            $valueObjectAttributes = $voMap->getColumnNamesFromAttributes($valueObjectAttributes);

            // Now (if setup in the entity map) we prefix the value object's
            // attributes with the snake_case name of the embedded class.
            $prefix = snake_case(class_basename($embed));

            foreach ($valueObjectAttributes as $key => $value) {
                $valueObjectAttributes[$prefix.'_'.$key] = $value;
                unset($valueObjectAttributes[$key]);
            }

            $attributes = array_merge($attributes, $valueObjectAttributes);
        }

        //*********************
        // New implementation
        // *****************->

        $embeddedRelations = $this->entityMap->getEmbeddedRelationships();

        foreach ($embeddedRelations as $relation) {
            // Spawn a new instance we can pass to the relationship method
            $parentInstance = $this->getMapper()->newInstance();
            $relationInstance = $this->entityMap->$relation($parentInstance);

            // Extract the object from the attributes
            $embeddedObject = $attributes[$relation];

            unset($attributes[$relation]);

            $attributes = $relationInstance->normalize($embeddedObject) + $attributes;
        }

        return $attributes;
    }