Reputation: 455
I have problem with doctrine embeddables and using associations in it. When i add @ManyToOne
to embedded entity doctrine don't create address_city
column in user table, however address_street
column is created. I seams bit strange because there is no error, city is silently ommited.
Code look like this:
/** @Entity */
class User
{
/** @Embedded(class = "Address") */
private $address;
}
/** @Embeddable */
class Address
{
/** @Column(type = "string") */
private $street;
/** @ManyToOne(targetEntity = "City") */
private $city;
}
/** @Entity */
class City
{
/** @Column(type = "string") */
private $name;
}
Upvotes: 6
Views: 1940
Reputation: 455
State for 2015.01.11:
This case is currently not supported in doctrine. It's now described in doctrine issue tracker here
Here is the explanation:
We don't support associations from embeddables right now...
It will probably not implemented for now, as embeddables (in our vision) are fitting the use-case of ValueObjects. ValueObjects are (usually) supposed to be containing serializable data, and an entity reference is not serializable data.
Upvotes: 9