mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Inheritance mapping: Entity has no field or association named username #6042
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 @bentcoder on GitHub (Aug 21, 2018).
Originally assigned to: @Ocramius on GitHub.
Support Question
Just wondering if I am doing something wrong or missing. I am not able to write a query to pull data from child class when I use entity repository of the parent class. Is such thing possible? If not what the best way of doing this rather than injecting the entity repository of the child class?
I get error below:
Thanks
ENTITY
REPOSITORY
I can solve the problem by injecting other entity repos like below and use the relevant one while using query builder but this wouldn't be scalable as you will guess!
@Ocramius commented on GitHub (Aug 21, 2018):
@BentCoder what's version 1.8.1? Can you check the ORM version in use?
@Ocramius commented on GitHub (Aug 21, 2018):
Can you check your example? Did you mean
locationhere?It is indeed correct that the
CountryReposiorycan't filter bylocation, since there is nolocationfield in acountry. You can only filter byUk.location.@bentcoder commented on GitHub (Aug 21, 2018):
@Ocramius
doctrine/orm 2.6.1doctrine/doctrine-bundle 1.8.1@Ocramius commented on GitHub (Aug 21, 2018):
Likely a duplicate of https://github.com/doctrine/doctrine2/issues/2237
@bentcoder commented on GitHub (Aug 21, 2018):
I've read that one and this one but I didn't really get what I meant to change in my example. If you don't mind, could you please tell me what I should change/use?
@Ocramius commented on GitHub (Aug 21, 2018):
@BentCoder you'd need to start selecting from the
$ukEntityRepository, or you can design the query differently (but in a more inefficient way):@bentcoder commented on GitHub (Aug 21, 2018):
This is currently what I am doing but as you will guess it will potentially lead me to inject many
EntityRepositoryparameters as my countries grow. It is OK for now because I have onlyukandfrbut more on the way so this is not an option for me.Looks like I have no option but go for this one.
Note: I think it would be perfect for everyone in future if we could just inject/use
EntityRepository $countryEntityRepository(parent) and query it (just to prevent injecting/using children).@Ocramius commented on GitHub (Aug 21, 2018):
I've already stated a clear NO in #2237 (DDC-16 - to give you an idea of how old this issue is) about that.