doctrine2 - Doctrine DQL instance of for multi table inheritance entity -


i have set doctrine multi table inheritance on application - see below

/**  * @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 {...}  

my custom repository query

$query = $this->getentitymanager()->createquery('select u mystorebundle:user u left join u.page p p instance of :newstype' )->setparameter('newstype', new news()); 

i thought work, keep getting following error:

notice: undefined index: id in /path/to/symfony/vendor/doctrine/orm/lib/doctrine/orm/abstractquery.php line 282 

obviously news entity doesnt have id field inherited when extending page class has id property defined, know im doing wrong?

thanks in advance

instance of expects entity class name, not instance:

->setparameter('newstype', 'yourproject\news'); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -