-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doctrine ORM 2.9: MappedSuperclass in entity hierarchy #8771
Comments
This changed in #8378 |
Thanks for the pointer, @greg0ire; do you know of any solution for this issue? |
I don't, I was just adding to this post because it might give you pointers as to who you might want to talk to about this, or whether this was deliberate or not. I think this might be worth a read too: #7825 Also, #8415 looks like it might fix your issue? I don't have a lot of time to help you right now, but you might have some helpful things to read in this repo's issues and PRs |
I tried the fix from #8415, but it does not seem to solve my issue I'm afraid :( AFAICS, I still have to choose between:
Thank you again for the pointers, though! I appreciate it. |
Its a bug this fails, i oversaw the mapped superclass case |
Glad to hear it, @beberlei! If you give me a hint as to how to fix it, maybe I can help? |
Just check for isMappedSuperclass in SchemaValifator to avoif the error |
@beberlei Thank you, it works fine for if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap) === false) { I still, however, have a Would you be OK with changing this for |
Ping @beberlei 🙂 |
@beberlei We're having the very same issue. It does not make much sense to me to require abstract classes to be a part of the discriminator map. If you feel like there is a reason to require it, let us know please. Otherwise I can prepare a PR with a fix :) Thank you! |
I found your comment (#8736 (comment)) and I even found a case when the behaviour is unexpected if the abstract class in the middle of hierarchy is not present (SchemaTool:183, relationship columns may not be created) Thank you! @beberlei |
@olsavmic Adding a fake entry for abstract classes does not fix all issues, please re-read the first post of this thread. |
@BenMorel I'm sorry, I was concerned only with the abstract class case since I somehow thought that the MappedSuperclass case was already resolved&merged. Anyway, it partially responds to your question:
Abstract entity classes (does not apply to |
Not sure why it should be this way, though I don't really mind, as long as Doctrine does not attempt to join a non-existing class! |
@BenMorel I want to make sure we’re on the same page.
The issue with MappedSuperclass in the middle of hierarchy is still there, Beberlei confirmed it’s a bug and it needs to be fixed. I’d prepare a PR but it’s rather your contribution. I just tested the case with joined table and:
Needs an entry in the discriminator map and a separate table exists (will be generated by schema diff) for this abstract class (which is implied by the JOINED behaviour and is valid from the DB schema point of view).
(Without |
Hi, there is still a regression in |
We have an entity hierarchy similar to:
This was working fine with Doctrine 2.8.
Since we upgraded to Doctrine 2.9 however,
bin/console doctrine:schema:validate
started failing with:I tried adding a "fake" entry to the discriminator map for the abstract class:
But now Doctrine attempts to
JOIN
a non-existing table when loading an entity in the hierarchy:How can I fix this?
A solution would be to make the intermediate abstract class an entity, but this would mean that
$product
would be moved from leaf entities to a newAbstractProductInvoiceItem
table, which adds an extraJOIN
to every query, and would mean a rather scary migration to do.Is there a better solution? Or are MappedSuperclasses not allowed in the middle of an entity hierarchy anymore?
The text was updated successfully, but these errors were encountered: