Doctrine DQL, class table inheritance and access to subclass fields

前端 未结 5 601
萌比男神i
萌比男神i 2020-12-29 06:15

I have a problem with a DQL query and entity specialization.

I have an Entity called Auction, which is OneToOne relation with Item

5条回答
  •  清酒与你
    2020-12-29 07:06

    The Doctrine team has stated that they're not going to add support for this:

    https://github.com/doctrine/orm/issues/2237

    Pertinent comments from that page:

    Thats indeed tricky. That syntax alone can, however, never work, because there might be several subclasses that have a field named "d", so Doctrine would not know which field you mean.


    I am closing this one.

    The requirement of this issue is basically violating OO principles.

    If you really need to filter across multiple child-entities in your inheritance, then try something as following instead:

    SELECT r FROM Root r WHERE r.id IN ( SELECT c.id FROM Child c WHERE c.field = :value )

提交回复
热议问题