Documentation of Concrete Inheritance #6047

Closed
opened 2026-01-22 15:25:26 +01:00 by admin · 24 comments
Owner

Originally created by @TerjeBr on GitHub (Aug 24, 2018).

The documentation of Concrete Inheritance when you use one table per class seems to be missing.

I only figured out you could use InheritanceType TABLE_PER_CLASS by looking at the source code.

Originally created by @TerjeBr on GitHub (Aug 24, 2018). The documentation of Concrete Inheritance when you use one table per class seems to be missing. I only figured out you could use InheritanceType TABLE_PER_CLASS by looking at the source code.
admin closed this issue 2026-01-22 15:25:27 +01:00
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

There are only 2 types of supported inheritance: single table and joined
table. Where did you find this other one?

On Fri, 24 Aug 2018, 10:19 Terje Bråten, notifications@github.com wrote:

The documentation of Concrete Inheritance when you use one table per class
seems to be missing.

I only figured out you could use InheritanceType TABLE_PER_CLASS by
looking at the source code.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakMPhmcBQQ4DAYESnW4a8Oti0v-F6ks5uT7b_gaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): There are only 2 types of supported inheritance: single table and joined table. Where did you find this other one? On Fri, 24 Aug 2018, 10:19 Terje Bråten, <notifications@github.com> wrote: > The documentation of Concrete Inheritance when you use one table per class > seems to be missing. > > I only figured out you could use InheritanceType TABLE_PER_CLASS by > looking at the source code. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371>, or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakMPhmcBQQ4DAYESnW4a8Oti0v-F6ks5uT7b_gaJpZM4WK8VP> > . >
Author
Owner
@TerjeBr commented on GitHub (Aug 24, 2018): https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/InheritanceType.php I also found it mentioned at https://www.doctrine-project.org/api/orm/latest/Doctrine/ORM/Mapping/InheritanceType.html
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

Hmm, interesting, I think this is new and only in master, not yet
anywhere. I'll ask internally, because I don't remember merging anything
related to this feature...
Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Fri, Aug 24, 2018 at 11:00 AM Terje Bråten notifications@github.com
wrote:

https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/InheritanceType.php

I also found it mentioned at
https://www.doctrine-project.org/api/orm/latest/Doctrine/ORM/Mapping/InheritanceType.html


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415698672,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakD4iNKtu9HLP5cM4SRanB-VDZyrAks5uT8C8gaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): Hmm, interesting, I think this is new and only in `master`, not yet anywhere. I'll ask internally, because I don't remember merging anything related to this feature... Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Fri, Aug 24, 2018 at 11:00 AM Terje Bråten <notifications@github.com> wrote: > > https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/InheritanceType.php > > I also found it mentioned at > https://www.doctrine-project.org/api/orm/latest/Doctrine/ORM/Mapping/InheritanceType.html > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415698672>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakD4iNKtu9HLP5cM4SRanB-VDZyrAks5uT8C8gaJpZM4WK8VP> > . >
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

It seems to be a deprecated feature instead of a new feature. It was in doctrine 1, but the schema tool in doctrine 2 does not support it.

So, if it is not supported, my question becomes: How do you have Base class A and Child class C be two different entities with two separate tables, but C inherits a lot of its fields (and mappings) from A?

@TerjeBr commented on GitHub (Aug 24, 2018): It seems to be a deprecated feature instead of a new feature. It was in doctrine 1, but the schema tool in doctrine 2 does not support it. So, if it is not supported, my question becomes: How do you have Base class A and Child class C be two different entities with two separate tables, but C inherits a lot of its fields (and mappings) from A?
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

I tried it out with no InheritanceType annotation in base class A, and the schema tool copied over all the normal table fields, but not the @ManyToOne relationships. Why is that?

@TerjeBr commented on GitHub (Aug 24, 2018): I tried it out with no InheritanceType annotation in base class A, and the schema tool copied over all the normal table fields, but not the `@ManyToOne` relationships. Why is that?
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

That's what JTI does

On Fri, 24 Aug 2018, 11:53 Terje Bråten, notifications@github.com wrote:

It seems to be a deprecated feature instead of a new feature. It was in
doctrine 1, but the schema tool in doctrine 2 does not support it.

So, if it is not supported, my question becomes: How do you have Base
class A and Child class C be two different entities with two separate
tables, but C inherits a lot of its fields (and mappings) from A?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415711808,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakJHT3puxwR7BgpCKRG3D7Im0_wAoks5uT80ngaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): That's what JTI does On Fri, 24 Aug 2018, 11:53 Terje Bråten, <notifications@github.com> wrote: > It seems to be a deprecated feature instead of a new feature. It was in > doctrine 1, but the schema tool in doctrine 2 does not support it. > > So, if it is not supported, my question becomes: How do you have Base > class A and Child class C be two different entities with two separate > tables, but C inherits a lot of its fields (and mappings) from A? > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415711808>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakJHT3puxwR7BgpCKRG3D7Im0_wAoks5uT80ngaJpZM4WK8VP> > . >
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

What is JTI?

@TerjeBr commented on GitHub (Aug 24, 2018): What is JTI?
Author
Owner
@TerjeBr commented on GitHub (Aug 24, 2018): Do you mean CTI? https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#class-table-inheritance
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

Joined table inheritance - same group of constants

On Fri, 24 Aug 2018, 11:58 Terje Bråten, notifications@github.com wrote:

What is JTI?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415712897,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakHUlwIC5bDl29puEahkKCpBDsAPYks5uT84ogaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): Joined table inheritance - same group of constants On Fri, 24 Aug 2018, 11:58 Terje Bråten, <notifications@github.com> wrote: > What is JTI? > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415712897>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakHUlwIC5bDl29puEahkKCpBDsAPYks5uT84ogaJpZM4WK8VP> > . >
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

But that joins the tables. I want two independent entities with no table joins.
All the columns that are the same in A and C should exist in both tables.

It is like A is a mapped super class for C, but also A is an entity on its own. Is that not possible?

@TerjeBr commented on GitHub (Aug 24, 2018): But that joins the tables. I want two independent entities with no table joins. All the columns that are the same in A and C should exist in both tables. It is like A is a mapped super class for C, but also A is an entity on its own. Is that not possible?
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

Yep, it's called "Joined" table inheritance all over the codebase

On Fri, 24 Aug 2018, 12:02 Terje Bråten, notifications@github.com wrote:

Do you mean CTI?

https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#class-table-inheritance


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415713870,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakMOOY_T9LPMXAOmFhOuh7sBuntGWks5uT88kgaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): Yep, it's called "Joined" table inheritance all over the codebase On Fri, 24 Aug 2018, 12:02 Terje Bråten, <notifications@github.com> wrote: > Do you mean CTI? > > https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#class-table-inheritance > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415713870>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakMOOY_T9LPMXAOmFhOuh7sBuntGWks5uT88kgaJpZM4WK8VP> > . >
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

No, that's not currently possible

On Fri, 24 Aug 2018, 12:05 Terje Bråten, notifications@github.com wrote:

But that joins the tables. I want two independent entities with no table
joins.
All the columns that are the same in A and C should exist in both tables.

It is like A is a mapped super class for C, but also A is an entity on its
own. Is that not possible?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415714645,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakOaxpsvMR-T83UmT4t8rpUVo1BL_ks5uT8_kgaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): No, that's not currently possible On Fri, 24 Aug 2018, 12:05 Terje Bråten, <notifications@github.com> wrote: > But that joins the tables. I want two independent entities with no table > joins. > All the columns that are the same in A and C should exist in both tables. > > It is like A is a mapped super class for C, but also A is an entity on its > own. Is that not possible? > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415714645>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakOaxpsvMR-T83UmT4t8rpUVo1BL_ks5uT8_kgaJpZM4WK8VP> > . >
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

Why is that not possible? Would that be problematic in some ways?

@TerjeBr commented on GitHub (Aug 24, 2018): Why is that not possible? Would that be problematic in some ways?
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

It's just not implemented 😬

On Fri, 24 Aug 2018, 12:07 Terje Bråten, notifications@github.com wrote:

Why is that not possible? Would that be problematic in some ways?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415715154,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakLAvG7yvCm1MExzKp1xUtm5N3SKqks5uT9BhgaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): It's just not implemented 😬 On Fri, 24 Aug 2018, 12:07 Terje Bråten, <notifications@github.com> wrote: > Why is that not possible? Would that be problematic in some ways? > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415715154>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakLAvG7yvCm1MExzKp1xUtm5N3SKqks5uT9BhgaJpZM4WK8VP> > . >
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

Was there a reason you put in the restriction that a Mapped superclass could not also be an Entity?

@TerjeBr commented on GitHub (Aug 24, 2018): Was there a reason you put in the restriction that a Mapped superclass could not also be an Entity?
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

Yes: a mapped superclass is alike to a trait in PHP: it's not supposed to
have concrete instances of its exact type at runtime, and it's only
supposed supposed to be abstract.

On Fri, 24 Aug 2018, 12:10 Terje Bråten, notifications@github.com wrote:

Was there a reason you put in the restriction that a Mapped superclass
could not also be an Entity?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415715953,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakMDPukpddkZ83ZBtTSvgMhZCewZmks5uT9EigaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): Yes: a mapped superclass is alike to a trait in PHP: it's not supposed to have concrete instances of its exact type at runtime, and it's only supposed supposed to be abstract. On Fri, 24 Aug 2018, 12:10 Terje Bråten, <notifications@github.com> wrote: > Was there a reason you put in the restriction that a Mapped superclass > could not also be an Entity? > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415715953>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakMDPukpddkZ83ZBtTSvgMhZCewZmks5uT9EigaJpZM4WK8VP> > . >
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

This forces me to change my class hierachy, just beacuse the way doctrine works.
I will have to have abstract class "Base", move all code from "A" to "Base" and then empty class "A" inherits "Base" and C inherits "Base". Instead of the more simple structure I first wanted where I just have the 2 classes "A" and "C".

@TerjeBr commented on GitHub (Aug 24, 2018): This forces me to change my class hierachy, just beacuse the way doctrine works. I will have to have abstract class "Base", move all code from "A" to "Base" and then empty class "A" inherits "Base" and C inherits "Base". Instead of the more simple structure I first wanted where I just have the 2 classes "A" and "C".
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

Yep, or you can help building the feature for 3.x :-)
Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Fri, Aug 24, 2018 at 12:21 PM Terje Bråten notifications@github.com
wrote:

This forces me to change my class hierachy, just beacuse the way doctrine
works.
I wil have to have abstract class "Base", move all code from "A" to "Base"
and then "A" inherits "Base" and C inherits "Base". Instead of the more
simple structure I first wanted where I just have the 2 classes "A" and "C".


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415718347,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakGD0f-jE_fehbHkxsEn91trPwxItks5uT9OQgaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): Yep, or you can help building the feature for 3.x :-) Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Fri, Aug 24, 2018 at 12:21 PM Terje Bråten <notifications@github.com> wrote: > This forces me to change my class hierachy, just beacuse the way doctrine > works. > I wil have to have abstract class "Base", move all code from "A" to "Base" > and then "A" inherits "Base" and C inherits "Base". Instead of the more > simple structure I first wanted where I just have the 2 classes "A" and "C". > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415718347>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakGD0f-jE_fehbHkxsEn91trPwxItks5uT9OQgaJpZM4WK8VP> > . >
Author
Owner

@TerjeBr commented on GitHub (Aug 24, 2018):

If I want this feature for 3.x, what would be the best way then?

Should I change Mapped Superclass to also allow it to be an entity?
Or should I introduce a new InheritanceType or try resurrect the InheritanceType TABLE_PER_CLASS?

@TerjeBr commented on GitHub (Aug 24, 2018): If I want this feature for 3.x, what would be the best way then? Should I change Mapped Superclass to also allow it to be an entity? Or should I introduce a new InheritanceType or try resurrect the InheritanceType TABLE_PER_CLASS?
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2018):

I'd say pursuing the TABLE_PER_CLASS approach would be best - try getting
in touch with @guilhermeblanco first, as he's been pushing these changes
that you are looking at. Heck, it may even be that master already
supports some of this stuff.
Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Fri, Aug 24, 2018 at 12:32 PM Terje Bråten notifications@github.com
wrote:

If I want this feature for 3.x, what would be the best way then?

Should I change Mapped Superclass to also allow it to be an entity?
Or should I introduce a new InheritanceType or try resurrect the
InheritanceType TABLE_PER_CLASS?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415720772,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakPF62h7CGq9J7GjTAvCSs9kXLxiGks5uT9YmgaJpZM4WK8VP
.

@Ocramius commented on GitHub (Aug 24, 2018): I'd say pursuing the TABLE_PER_CLASS approach would be best - try getting in touch with @guilhermeblanco first, as he's been pushing these changes that you are looking at. Heck, it may even be that `master` already supports some of this stuff. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Fri, Aug 24, 2018 at 12:32 PM Terje Bråten <notifications@github.com> wrote: > If I want this feature for 3.x, what would be the best way then? > > Should I change Mapped Superclass to also allow it to be an entity? > Or should I introduce a new InheritanceType or try resurrect the > InheritanceType TABLE_PER_CLASS? > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7371#issuecomment-415720772>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakPF62h7CGq9J7GjTAvCSs9kXLxiGks5uT9YmgaJpZM4WK8VP> > . >
Author
Owner

@Pictor13 commented on GitHub (Nov 21, 2019):

Ping 🙃
In the end was there anything on master that would allow this TABLE_PER_CLASS-like inheritance?

@Pictor13 commented on GitHub (Nov 21, 2019): Ping 🙃 In the end was there anything on `master` that would allow this TABLE_PER_CLASS-like inheritance?
Author
Owner

@MichaelKubovic commented on GitHub (Nov 29, 2019):

hey @TerjeBr, how did you deal with the issue?

@MichaelKubovic commented on GitHub (Nov 29, 2019): hey @TerjeBr, how did you deal with the issue?
Author
Owner

@TerjeBr commented on GitHub (Nov 29, 2019):

I just went on with other things. Sorry.

@TerjeBr commented on GitHub (Nov 29, 2019): I just went on with other things. Sorry.
Author
Owner

@mpdude commented on GitHub (Jun 26, 2023):

There is no "concrete table inheritance" implemented, and to my knowledge, nobody is trying to implement it.

I suggest we close this issue.

@mpdude commented on GitHub (Jun 26, 2023): There is no "concrete table inheritance" implemented, and to my knowledge, nobody is trying to implement it. I suggest we close this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6047