mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3334: Allow to set @Id in @AttributeOverride #4119
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 (Oct 2, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user j_schumann:
Hello!
@AttributeOverride only allows to change the column definition of a property that is defined in a parent class or trait. It is not possible to define such an "foreign" column (through inheritance/trait) as ID column and also there is no possibility define the primary key through any other annotation.
It would be greatly useful to extend the @AttributeOverride to allow specification of @ID, @GeneratedValue and @CustomIdGenerator in this annotation as those are also property/attribute related and there is no reason those should not be overrideable.
Example:
@taylankasap commented on GitHub (Jul 20, 2016):
I expect the usage should be like this:
But I don't think this should be limited to certain annotations (e.g.
@ORM\Id). Adding custom annotations should be possible. For example I need to add@Gedmo\SortableGroupand I thought this might work:But the error message is (same with error message for
@ORM\Id)Apparently DocParser thinks I'm trying to use this annotation on the class itself instead of understanding it is an override.
Also if this is going to become a thing than
Doctrine\ORM\Mapping\AttributeOverride::$columnlooks wrong if it's name implies only@ORM\Columnis overridable. If that's the case something likeDoctrine\ORM\Mapping\AttributeOverride::$annotationmight be better.@taylankasap commented on GitHub (Jul 20, 2016):
Also if you make it like this, I think
@ORM\AssociationOverrideswill no longer be needed. If I'm not missing something, that is.@MatTheCat commented on GitHub (Jun 20, 2017):
I just stumbled upon this, could this be implemented someday?
@ipesanz commented on GitHub (Aug 26, 2017):
I was searching to have different strategies of Generating ID depending on which subclas of User amb I declaring, for example:
Abstract User @Entity Class, @inheritanceType = SingleTable --> estrategy Auto (althought i cant declare this type)
Of course I have to take care of this way, but I was dealing which way to do and I was not able to find anything related so.... I change my mind