0 votes

Appearantly there currently is no support for Mapped Superclasses. My Entity extends an abstract Mapped Superclass and the import feature only detects and imports the entity itself. So an ID field is auto generated (not as PK) for the entity while it is actually defined in the mapped superclass.

in Solved by (150 points)
recategorized by

1 Answer

0 votes
Best answer

ORM Designer supports Mapped superclass as much as it is possible.

It depends on ORM (Doctrine or Doctrine2) and format you're using (XML, YML, or Annotations). For example for Doctrine2 and PHP code:

/** @MappedSuperclass */
class MappedSuperclassBase
{}

/** @Entity */
class EntitySubClass extends MappedSuperclassBase
{}

There is no annotation which define that EntitySubClass is defined from MappedSuperclass. But in this case, ORM Designer also parse extends keyword and after few hacks can attach MappedSuperclass with EntitySubclass.

Unfortunately in YML/XML code, there is no way how to get this information. XML definition of mapped superclass and derived entity looks like this:

 <mapped-superclass name="a">
    <id name="id" type="integer">
      <generator strategy="AUTO"/>
    </id>
  </mapped-superclass>

  <entity name="b">
    <field name="age" type="integer" nullable="true"/>
  </entity>

And as you can see, there is no mention about relation between entity a and entity b. This relation is available only in PHP code and if you're using ORM Designer to import XML/YML, this is one of the few information (I think it's only this one) which can't be imported directly.

For this cases you need to add this inheritance manually to your model.

by Skipper developer (141k points)
selected by

I use Doctrine2 annotations and the fields of the mapped superclass are missing. Actually, the whole mapped superclass is not imported. Please have a look at our code below.

This is the entity:

/**
 * @ORM\Table(name="accommodation")
 * @ORM\Entity(repositoryClass="Repository\AccommodationRepository")
 */
class Accommodation extends AbstractReviewable

And this is the mapped superclass:

/**
 * @ORM\MappedSuperclass
 */
abstract class AbstractReviewable

Perhaps it doesn't work because it is an abstract class?

In case you described ORM Designer should be able to import mapped superclass. It is probably some problem in our PHP parser.

Could you please send us a full source code of your two classes to [email protected]? (You can erase any function logic, only the main structure is important)

Thank you
Ludek