2

I would like to set up transitive persistence in the single table inheritance mapping I’ve developed with doctrine in zf2. I’ve set up the mapping similar to the example presented in doctrine’s documentation for single table inheritance:

/**
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
 */
class Person
{
    // ...
}

/**
 * @Entity
 */
class Employee extends Person
{
    // ...
}

If a record from the Employee table ever gets damaged or goes missing, I'd like for it to get replaced. However, the example above does not provide for that functionality on its own and doctrine won't allow me to write an INSERT dql in an error checker because they say entities and their relations have to be introduced into the persistence context through EntityManager#persist() to ensure consistency of your object model.

Examples in doctrine’s documentation for cascade operations show a neat way to place cascade settings in a @OneToMany mapping statement. However, none of the class table inheritance mapping statements (@InheritanceType, @DiscriminatorColumn, or @DiscriminatorMap) seem to want to accept cascade settings this way.

How and where can the cascade operations be configured for a single table inheritance strategy?

jcropp
  • 1,236
  • 2
  • 10
  • 29

0 Answers0