mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-3206: Possible to remove inversedBy (use only mappedBy)? #3971
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 (Jul 5, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user weaverryan:
Hi guys!
This is another developer experience situation. Here is the flow:
mappedByattribute so that it points to the exact property/relationship we're dealing withinversedBy.Why is step 3 (inversedBy) needed? Isn't this redundant information, since the
mappedByfully maps out that these 2 associations form different sides of the same relationship? I would love to remove this, I hate explaining to people starting with relationships to now go back to the main entity to add this key. It feels like duplication, which I think people sense.Of course, I very well may be wrong and it may be needed :).
Thanks!
@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by @ocramius:
I'd suggest doing the opposite: dropping
mappedBy.I'm not sure why JPA introduced this sort of bidirectional mapping, but for practical purposes, it makes it possible for us to load metadata for associations on both sides of the associations. Without having both
mappedByandinversedBywe'd be forced to scan through all existing mappings to find which pieces of the jigsaw fit together.I don't think we have a good solution for this except for a "build mappings" step that warms up a cache, and that's a very radical architectural change that we can only introduce in 3.x
@doctrinebot commented on GitHub (Jul 7, 2014):
Comment created by Nek:
Hi, please excuse me if what I say is wrong and do not hesitate to correct me, it's my first immertion in Doctrine code :) .
So I checked a little bit the situation in the code. I don't see the problem dropping inversedBy. It's easier understandable for the final user.
In facts right now the ManyToMany work very well with only
mappedByoptions so theinvertedByis clearly a duplicated information.The problem for the implementation of this feature is that the ownerSide is decided by a single method for every mappings, so she's quite complexe. So the method decide only on using
mappedByandinvertedBy. This behavior should be modifiable without too much troubles.https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1353
But another problem here is that should be discuss is that it's a big BC Break.