I've added class B to the discriminator map so now I have

inheritanceType: JOINED
    discriminatorColumn:
        name: type
        type: string
    discriminatorMap:
        B:B
        C:C
        D: D
        E: E

Obviously no record has the B type. The problem now is that if I run the 
DQL query to get B-type records I get an empty array while there is one item
that is child of B that is not retrieved.

What am I missing?


Il giorno giovedì 4 dicembre 2014 23:41:51 UTC+1, Jàπ (Jasper N. Brouwer) 
ha scritto:
>
> If you want to be able to filter on "instanceof B", you'll need to add B 
> to the discriminator map. 
>
> If class B is in fact an abstract class, you won't be able to instantiate 
> it, so you can't persist it, so it will never reach the database, so 
> Doctrine cannot find and hydrate it. In other words: you're safe adding it 
> to the discriminator map. 
>
> -- 
> Jasper N. Brouwer 
> (@jaspernbrouwer) 
>
>
> On 4 December 2014 at 18:32:24, Stefano Angaran ([email protected] 
> <javascript:>) wrote: 
> > Hi all, 
> > I'm using Doctrine for my project and all is fine but I've encountered a 
> > problem when trying to implement a three levels class hierarchy. 
> > 
> > I had a two levels hierarchy but now I need to implement an extension to 
> my 
> > model and add an additional level to one of my classes, 
> > 
> > The initial situation was like B and C inherit from B, now there is D 
> and E 
> > which inherit from B. I want to implement this using Class Table 
> > Inheritance as this was the initial choice. B is now an abstract class 
> as 
> > it cannot be instantiated alone. 
> > 
> > I can make it almost work by setting the discriminator map in the top A 
> > class but when I use the A repository I'm not able to search 
> > only instance of B now, I can only look for instance of D o E. 
> > 
> > If I use this DQL 
> > 
> > SELECT root FROM A root WHERE root INSTANCE OF B 
> > 
> > I get exception 
> > 
> > Cannot check if a child of 'A is instanceof 'B', inheritance hierarchy 
> > exists between these two classes. 
> > 
> > My mapping information is in Yaml format: 
> > 
> > inheritanceType: JOINED 
> > discriminatorColumn: 
> > name: type 
> > type: string 
> > discriminatorMap: 
> > C:C 
> > D: D 
> > E: E 
> > 
> > Can you help me, please? If you need something else to better understand 
> > this let me know! 
>
>
>

-- 
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