Here it is. I've made some edit to reduce attributes number but the
structure is intact
SELECT p0_.id AS id0, p0_.name AS name1, c1_.attr AS attr6, f3_.sku AS
sku7, c5_.foo AS foo8, c5_.bar AS bar9, p0_.type AS type12 FROM A p0_ LEFT
JOIN C c1_ ON p0_.id = c1_.id LEFT JOIN B f3_ ON p0_.id = f3_.id LEFT JOIN
D f4_ ON p0_.id = f4_.id WHERE p0_.type IN ('B')
Only B is added in the WHERE expression. Am I doing something wrong or is
it how it's supposed to work?
Il giorno venerdì 5 dicembre 2014 10:20:26 UTC+1, Marco Pivetta ha scritto:
>
> Can you check the generated SQL for your DQL?
> On Dec 5, 2014 10:14 AM, "Stefano Angaran" <[email protected]
> <javascript:>> wrote:
>
>> 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])
>>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
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.