mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Analog of features @WhereJoinTable and @JoinColumnsOrFormulas from Spring Hibernates. #6793
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 @rosamarsky on GitHub (Aug 2, 2021).
Feature Request
Imagine I have a million entities, and each of them should be commentable.
so I create a table like this:
Of course, you will say that I need to use Inheritance Table in mapping, but if I do this then I need to create million classes like
EachClassComment extends Comment. So I want to have simple one-to-many relation withjoin by object_id = id AND object_type = <value>; I already tried do this dirty by this way and it works:As you see I wrote
@ORM\JoinColumn(name="object_type", referencedColumnName="entity_type")that means I need to add columnentity_typein DB for each commentable entities table.I know in Hibernate(Java - Spring framework) this possible to do with different simple ways. For example:
But Doctrine has no features like
WhereJoinTableandJoinColumnOrFormula.Summary
Nice to have at least one of the features written above.
WhereJoinTablelooks not difficult to make.Even something like this @ORM\JoinColumn(name="object_type", value=Provider::ENTITY_NAME) partially solve this issue
Thanks guys.