This is a tricky case to solve with Doctrine. You cannot use a Mapped Superclass, because you cannot reference it in an association (you can only point to real entities).
So inheritance (STI or CTI) is the only solution if you want to go down this road. http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html#single-table-inheritance http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html#class-table-inheritance I'm not entirely sure what your complete use-case is, but it might be wise to consider if you want to solve it using full blown entities (in stead of plain sql/dql). -- Jasper N. Brouwer (@jaspernbrouwer) On 20 January 2015 at 12:49:30, Rekam ([email protected]) wrote: > Hi, > > I'm searching for a way to override associations mapping in subclasses. I > saw this part of documentation but, unless I didn't understand something, > it doesn't give me an answer: > > http://doctrine-orm.readthedocs.org/en/latest/tutorials/override-field-association-mappings-in-subclasses.html > > > Let's take this example: > > ... > > I use this as a base package to manage user. Now in a project, I need very > specific stuff about RoleType, and need to add some DB columns to this > table. Some stuff that has nothing to do in a base package. I would > normally do something like this: > > ... > > Now I need to reference this GreatRoleType from my Role class, so I need to > extend it as well > > ... > > But then, I need to extend the Group class to target GreatRole instead > of Role. And in the end, I need to extend User to target GreatGroup (which > targets GreatRole, which targets GreatRoleType) Is there a way to avoid > this cascade of extends? Or is there a best practice out there that is > totally different from what I did? > > Do I need to use MappedSuperClasses? > > In the end, when I fetch a User, I would like to join Group, Role and > RoleType. If I change the last for GreatRoleType, I will need to update the > whole chain of joins. Because ->from('User', 'u')->leftJoin('u.groups', > 'g')->leftJoin('g.roles', 'r')->leftJoin('r.type', 't'); will fetch > explicitely User, Group, Role and RoleType. > > Thanks for your help! -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
