0
我有兩個模型:NoteItem和TaskItem。兩者都擴展AbstractStreamItem。Doctrine獲取擴展給定抽象類的所有模型的存儲庫
class AbstractCommentsItem {
...
}
class CommentItem extends AbstractCommentsItem {
...
}
class TaskItem extends AbstractCommentsItem {
...
}
現在我想要在一個getRepository命令中獲取兩個模型的存儲庫。
有沒有可能?我想過單表繼承,但不知道是否是正確的方法。
好吧,我現在有點困惑。所以AbstractCommentsItem應該是@InheritanceType(「SINGLE_TABLE」)?是否有使用@MappedSuperclass的解決方案,因爲呈現的類結構讓我更加想起這種方法。 – julew
好吧,@MappedSuperclass不會在這裏工作。在文檔中發現:「映射超類不能是一個實體,它不能查詢」。 – julew