Bug #31497

ManyToOne relation fields are not added for inheritance hierarchy

Added by Andreas Wolf about 9 years ago. Updated over 8 years ago.

Needs Feedback
Should have
Start date:
Due date:
% Done:


Estimated time:


I have one (abstract) superclass with several subclasses. There is a n:1 relation in the superclass:

abstract class Employee {
   * @ORM\ManyToOne
   * @var Employer
  protected $employer;

class Manager extends Employee {

class Worker extends Employee {

When executing doctrine:migrate, all tables are created. The subclass tables also contain all non-relational fields from the superclass. The employee table (for the abstract class) even contains the employer field, but all tables for derived classes do not. This leads to errors when trying to save a record ("#42S22: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'employer' in 'field list'").

In general I would have expected a table structure like for the party package: All identifiers from all tables in the abstract table, with the fields from the abstract class plus a dtype field that denotes the record type; the rest of the information is stored in the accordant table.


Updated by Andreas Wolf about 9 years ago

Ahhh... Seems the code got messed up. Could somebody clean this up? :)


Updated by Andreas Wolf about 9 years ago

Oh, and I forgot one thing: All classes (also the abstract one) are tagged with @FLOW3\Entity.


Updated by Karsten Dambekalns almost 9 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Karsten Dambekalns

Just to make sure: you have an @InheritanceType annotation on your superclass?


Updated by Karsten Dambekalns over 8 years ago

  • Project changed from Doctrine 2 to Doctrine.ORM

Updated by Sebastian Wojtowicz over 8 years ago

I have the same problem, ChristianM confirmed it http://www.rvantwisk.nl/flow3-irc-log/2012/july/19.html.

In my case, I can't add the @InheritanceType annotation on the superclass, because the superclass is TYPO3/Media/Domain/Model/Image and I don't want to make changes there.

It's easy to confirm this, just create an empty class that extends TYPO3/Media/Domain/Model/Image and run doctrine:update.

You'll see that in the newly created database table you have columns for all properties of the parent image class except the resource column. And of course this produces the same error when objects are meant to be persisted.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'resource' in 'field list'

Also available in: Atom PDF