是否有可能以某种方式将单个实体类映射到两个不带继承的不同表?
类似的东西:
<entity name="Acme\Entity\Service" table="organization_service">
...
<many-to-one field="target" target-entity="Acme\Entity\Organization" inversed-by="services">
<join-columns>
<join-column name="target_id" referenced-column-name="id" />
</join-columns>
</many-to-one>
</entity>
<entity name="Acme\Entity\Service" table="person_service">
...
<many-to-one field="target" target-entity="Acme\Entity\Person" inversed-by="services">
<join-columns>
<join-column name="target_id" referenced-column-name="id" />
</join-columns>
</many-to-one>
</entity>
实体类可能如下所示:
class Service
{
...
/**
* @var Person|Organization
*/
private $target;
}
class Person
{
...
/**
* @var Service[]
*/
private $services;
}
class Organization
{
...
/**
* @var Service[]
*/
private $services;
}
到目前为止我找到的解决方法是创建两个具有相同内容的PersonService和OrganizationService类,并相应地将它们映射到“person_service”和“organization_service”表。