mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 09:23:20 +02:00
DDC-3386: Multiple Level Discriminator Mapping #4183
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 @doctrinebot on GitHub (Nov 11, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user DrugCrazed:
We currently have a situation where we're required to have up to 4 levels of discriminator mappings, and we're finding that Doctrine will insert into our root entity table, and the leaf entity table correctly. However, the tables in between are not being set at all.
The hierarchy is below:
When inserting an
ItemSpecificentity, I found that theDealandItemSpecifictables were filled but the EcommerceDeal was not.There's not much documentation about trees that are slightly more complicated than the
Employee,Person,Adminexample in the docs so there's a chance I've misunderstood how to build the tables correctly.Currently we only have one discriminator column on the
Dealtable. Should we instead be setting up several columns that are nullable and setting new discriminator columns further down the tree?EDIT: All classes are Class Table Inheritance, in case that is unclear
@doctrinebot commented on GitHub (Nov 11, 2014):
Comment created by DrugCrazed:
The thing that always confuses me while I'm working on this is the fact that I can select from the Database fine. I've got dummy data in each table and Doctrine is clever enough to select all the correct fields from the correct tables so I'm unsure whether I've made a mistake or if Doctrine has a bug.
@doctrinebot commented on GitHub (Nov 11, 2014):
Comment created by @ocramius:
This looks like normal ORM behavior to me, not really requiring any change. What's the reason for inserts on the other tables?
@doctrinebot commented on GitHub (Nov 12, 2014):
Comment created by DrugCrazed:
We have data that's the same across all Ecommerce Deal types (things like the start time, end time etc). I'd expect to be able to set all the values on (say) an
ItemSpecificdeal and Doctrine to insert the generic data in theEcommerceDealtable.@doctrinebot commented on GitHub (Nov 12, 2014):
Comment created by DrugCrazed:
It turns out that Doctrine does support this out of the box. A predecessor had overriden the
JoinedSubclassPersisterwith the sole purpose being to comment out the section relating to discriminator columns.@doctrinebot commented on GitHub (Nov 12, 2014):
Comment created by DrugCrazed:
Problem is with an overridden method not in the Doctrine core.
@doctrinebot commented on GitHub (Nov 13, 2014):
Comment created by @ocramius:
[~DrugCrazed] do you mean that your version (local file) of the
JoinedSubclassPersisterwas monkey-patched?@doctrinebot commented on GitHub (Nov 13, 2014):
Comment created by DrugCrazed:
Undoing monkey patch does not fully fix issue
@doctrinebot commented on GitHub (Nov 13, 2014):
Comment created by DrugCrazed:
Marco: We'd overridden a whole bunch of classes to do various things, but I've got no idea what those were (these happened at least 6 months before I joined).
The
JoinedSubclassPersisterwas overridden and just commented out two linesFrom speaking to people, it seems that the point of using that was to allow the discriminator columns to be on the incorrect tables.
However, even with undoing this, I've just tried to create a
ComboDealand it inserted into the root table and the leaf table but none of the other tables. However it looks likeItemSpecificentities are fine. I'll just retry creation of each entity type and get back to you.@doctrinebot commented on GitHub (Nov 13, 2014):
Comment created by DrugCrazed:
Just finished doing that. I can create
EcommerceDealentities, andItemSpecificentities and they'll insert into the correct tables (so theEcommerceDealentity saves into theEcommerceDealandDealtables, and theItemSpecificentity saves into theItemSpecific,EcommerceDealandDealtables).The rest only insert into the
Dealtable and the table relating to that class.@doctrinebot commented on GitHub (Nov 18, 2014):
Comment created by DrugCrazed:
Is there an update on how we can resolve this?
@doctrinebot commented on GitHub (Nov 18, 2014):
Comment created by DrugCrazed:
We've spent a day looking through and trying to work out what seems to be happening and seem to have a resolution.
It appears that the method of getting the parents was only getting those which weren't transient (and thus were entities), which in our case wasn't working since then Doctrine complains about duplicate column definitions. After overriding the getParentClass to allow us to be explicit we got it to work.