Problems of Discrimination with Doctrine 2

I am implementing inheritance mapping with D2 using the table class inheritance strategy. I have a parent class called Person with the following code code

namespace Zain\Entity;
/**
 * @Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="Specialty", type="string") // what other types exist?
 * @DiscriminatorMap({"person" = "\Zain\Person", "employee" = "\Staff\Entities\Employee"})
 *  
 * @Table(name="db_One.tblPerson")
 *
 */
class Person
{

...

And I have a child class called Employee with the following code:

namespace Staff\Entities;

/**
 * Description of Employee
 * @Entity
 * @Table(name="db_Two.tblEmployee")
 * 
 */

class Employee extends \Zain\Entity\Person
{

...

MySQL table: tblPerson has a Discriminator column called Specialty, defined as:

`Specialty` varchar(45) NOT NULL

The problem occurs when I have an instance of Employee and try to save it.

When the Employee instance is saved, I expect the object name, employee (row) to be stored in the Specialty column of the Person table. However, this did not happen. I come across an error message:

Message: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'specialty' cannot be null

, , Specialty SQL, EntityManager. Not Null tblPerson > Column Specialty.

, , . , , SQL, / persist?

, . .

+3
1

Doctrine . DiscriminatorMap string integer ( : bigint, smallint, float,...).

, - , . , "\" . , .

+2

All Articles