Widget
is a MappedSuperclass (no table) and Form
has a 1-n key to it. Since every subclass of Widget
will live in its own table, this is not a valid relation. Or in other words MappedSuperclass may not have a n-1 relation (think of it more like a decorator).
You could use the generic foreign key paradigm to do it like you wanted or use single table inheritance for the widget
, which is better for your case (ref http://docs.doctrine-project.org/en/latest/reference/inheritance-mapping.html#single-table-inheritance.)
table Widget(id, type)
table WidgetXY(id, X, Y)
table WidgetQR(id, Q, R)
A new WidgetXY
entity would result in row of Widget(id=7, type=1)
AND a row of WidgetXY(id=7, X, Y)
. A controller (doctrine) would identify a type=1
row referring to WidgetXY
by using a discriminator map, on the database level you just join against the correct table, pkeys 1-1.
In doctrine you have to set the inheritance type to joined and define your discriminator map in the annotations (see link above)
hth