我已经在我的应用程序上设置了 Doctrine 多表继承 - 见下文
/**
* @Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="type", type="string")
* @DiscriminatorMap({
* "news" = "News" ,
* "press_release" = "PressRelease"})
*
* @table(name="pages")
*/
class PressRelease extends Page {...}
class News extends Page {...}
我的自定义存储库查询
$query = $this->getEntityManager()->createQuery('SELECT u FROM MyStoreBundle:User u
LEFT JOIN u.page p
WHERE p INSTANCE OF :newsType'
)->setParameter('newsType', new News());
我认为这会起作用,但是我不断收到以下错误:
Notice: Undefined index: id in /path/to/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 282
显然我的News
实体没有一个字段,因为这是在扩展定义了属性的类id
时继承的,有谁知道我做错了什么?Page
id
提前致谢