i have this situation
<entity name="Company\Entity\User\User" table="usr_user" inheritance-type="JOINED">
<unique-constraints>
<unique-constraint name="username_UNIQUE" columns="username" />
</unique-constraints>
<discriminator-column name="discriminator" />
<discriminator-map>
<discriminator-mapping value="guest" class="\Company\Entity\User\Guest"></discriminator-mapping>
<discriminator-mapping value="user" class="\Company\Entity\User\User"></discriminator-mapping>
</discriminator-map>
<id name="id" type="integer" column="id">
<generator strategy="AUTO" />
</id>
<field name="username" type="string" column="username" length="255" />
<field name="password" type="string" column="password" length="50" />
</entity>
<entity name="Company\Entity\User\Guest" table="usr_guest">
<id name="id" type="integer" column="id">
<generator strategy="AUTO" />
</id>
<field name="additionalField1" type="string" column="additional_field_1" length="255" />
<field name="additionalField1" type="string" column="additional_field_2" length="255" />
</entity>
When i generate entities i add the inheritance
class User {
// Some code...
}
class Guest extends User{
// Some code...
}
The problem appears whe i try to update database schema because of the same "id" column name of both the entities. I've tryied to add an attribute override but i guess this is not the proper way
<entity name="Company\Entity\User\Guest" table="usr_guest">
<id name="id" type="integer" column="id">
<generator strategy="AUTO" />
</id>
<field name="additionalField1" type="string" column="additional_field_1" length="255" />
<field name="additionalField1" type="string" column="additional_field_2" length="255" />
<attribute-override name="id">
<field column="guest_id" />
</attribute-override>
</entity>
I've tryied also to change the property name (not the column name) in guest_id but the error is the same
[Doctrine\ORM\Mapping\MappingException]
Duplicate definition of column 'id' on entity 'Company\Entity\User\Guest' in a field or discriminator column mapping.
Do i have to change the Guest "id" column name? Where am i wrong?
Thank You
To make the status of this question to answered and from this :
<entity name="Company\Entity\User\Guest" table="usr_guest">
<field name="additionalField1" type="string" column="additional_field_1" length="255" />
<field name="additionalField1" type="string" column="additional_field_2" length="255" />
<attribute-override name="id">
<field column="guest_id" />
</attribute-override>
</entity>
<entity name="Company\Entity\User\User" table="usr_user" inheritance-type="JOINED">
<id name="id" type="integer" column="id">
<generator strategy="AUTO" />
</id>
<unique-constraints>
<unique-constraint name="username_UNIQUE" columns="username" />
</unique-constraints>
<discriminator-column name="discriminator" />
<discriminator-map>
<discriminator-mapping value="guest" class="\Company\Entity\User\Guest"></discriminator-mapping>
<discriminator-mapping value="user" class="\Company\Entity\User\User"></discriminator-mapping>
</discriminator-map>
<field name="username" type="string" column="username" length="255" />
<field name="password" type="string" column="password" length="50" />
</entity>
You must delete the primary key on inherited table, because it's already declared on the mother table.