[Solved] Support embedding value objects in Doctrine

0 votes
asked Apr 9, 2016 in Solved by cvuorinen (320 points)
recategorized May 28, 2016 by ludek.vodicka

Is there currently support for embedding value objects to Doctrine entities?
http://docs.doctrine-project.org/en/latest/tutorials/embeddables.html

At least, I couldn't find a way to do it.
If not, could you please consider adding support for it?

1 Answer

0 votes
answered Apr 9, 2016 by ludek.vodicka Skipper developer (140,450 points)
selected Apr 11, 2016 by cvuorinen
 
Best answer

Sure, embeddables are fully supported.

http://i.imgur.com/3N5JeEk.png

commented Apr 10, 2016 by cvuorinen (320 points)

Yes, I saw that. But how can it be used to embed a value object that is not an entity?

I would like to have a value object that lives in a separate namespace from entities and does not have the @ORM\Entity annotation, and has @ORM\Embeddable annotation instead (as in the example I linked to in the question).

commented Apr 10, 2016 by ludek.vodicka Skipper developer (140,450 points)

As soon as you embed entity object it automatically becomes value object.

Feel free to try it in Skipper and in case that export will not be what you need please post expected schema file together with your Skipper file so we can help you

commented May 28, 2016 by cvuorinen (320 points)

Ok, that works. Thanks!

Just wasn't that intuitive to create an entity when I wanted a value object.

...