Doctrine DQL, class table inheritance and access to subclass fields

前端 未结 5 498
萌比男神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 06:49

    I had the same issue, and didn't find a solution without using separate queries for each subclass and merging them later on the application level.

    One thing I'm sure, single table inheritance will not solve this, completely the same thing.

    There is another alternative, although being logically dirty. Define all the fields (the ones you need) in the superclass. If the record logically doesn't have that field it will be empty. Not a pretty sight, but hey, more optimized than 2-3-4-... queries. Also in this scenario single table inheritance is definitely the better way to go

提交回复
热议问题