Hello,

On 22 September 2014 11:38, Julien Goux <[email protected]> wrote:

Hello,
> I know this problem has already been discussed, but I can't find any
> solution to my problem.
> I use single table inheritance on my Element entity (abstract class).
> Element entity has two concrete implementation : CodedTextElement and
> NumericElement.
> The CodedTextElement has a oneToMany relationship with CodedText entity.
>
> In top of it, I have a Result entity which contains one Element (could be
> NumericElement or CodedTextElement).
> Now I need to retrieve a Result with its TextCodedElement and its
> associated CodedTexts.
> Here is my query :
>
>         $queryBuilder = $this->_em->createQueryBuilder();
>         $queryBuilder
>             ->select('res', 'e', 'c')
>             ->from('Domain\Model\Result', 'res')
>             ->leftJoin('res.element', 'e')
>             ->leftJoin('e.codedTexts', 'c')
>             ->where('e INSTANCE OF Domain\Model\CodedTextElement AND res.id = 
> :id')
>             ->setParameter('id', $id);
>         return $queryBuilder->getQuery()->getOneOrNullResult();
>
>
>
> As expected, Doctrine throws an error on the e.codedTexts association
> which is not defined on Element (but on CodedTextElement).
> How can I rewrite this query to achieve what I want ? :/
>

Did you already check stackoverflow? I pretty much replied to this question
in http://stackoverflow.com/a/14854067/347063

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to