mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Documentation of Concrete Inheritance #6047
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@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:
@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
@Ocramius commented on GitHub (Aug 24, 2018):
Hmm, interesting, I think this is new and only in
master, not yetanywhere. 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:
@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):
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
@ManyToOnerelationships. Why is that?@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:
@TerjeBr commented on GitHub (Aug 24, 2018):
What is JTI?
@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
@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:
@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?
@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:
@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:
@TerjeBr commented on GitHub (Aug 24, 2018):
Why is that not possible? Would that be problematic in some ways?
@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:
@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?
@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:
@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".
@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:
@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?
@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
masteralreadysupports 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:
@Pictor13 commented on GitHub (Nov 21, 2019):
Ping 🙃
In the end was there anything on
masterthat would allow this TABLE_PER_CLASS-like inheritance?@MichaelKubovic commented on GitHub (Nov 29, 2019):
hey @TerjeBr, how did you deal with the issue?
@TerjeBr commented on GitHub (Nov 29, 2019):
I just went on with other things. Sorry.
@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.