Many-To-One with multiple target entities

后端 未结 1 1125
星月不相逢
星月不相逢 2021-01-01 23:07

This seems simple but I can\'t get it right:

There are three entities: Fruit, Vegetable and Snack. Snack has the fields

相关标签:
1条回答
  • 2021-01-01 23:48

    You can create a (abstract) mapped superclass called Food, which can hold some basic information for Fruit and Vegetable.

    The keyword for your question is inheritance mapping, this is the documentation for it: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#inheritance-mapping

    Then you could reference this mapped superclass in your entity relationship.

    0 讨论(0)
提交回复
热议问题