mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
One to many relation return partial collection of object #5270
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 @hlecuyer on GitHub (Sep 22, 2016).
I have a strange behavior with doctrine 2.5 . I have a one to many relationship who doesn't return the expected result.
I have the following entities :
And when call
$order->getOrderActors(), there is missing object in the collection result althought they are in the database. It's always the same object missing, the one with the roleowner.To make it work, i have two workaround:
$em->getRepository(OrderActor::class)->findBy(['order' => $order]))ownerfrom my database with the queryBuilder.After the following query, then the call to$order->getOrderActors()works fine.Last hack, if place a $em->clear() between two request, sometimes it works.
I couldn't find anything similar on the issues I found. If you have a clue, that would be very helpfull.
@coudenysj commented on GitHub (Sep 27, 2016):
@hlecuyer Can you check the SQL used when calling
$order->getOrderActors()?@hlecuyer commented on GitHub (Sep 27, 2016):
I couldn't find this particular call in the list that I have. The only call referecing to the ordorActors entity where include with a join in one of the previous request. Is there a easy way to do so?
@coudenysj commented on GitHub (Sep 27, 2016):
As you fetch the association eagerly, it should show up as a join in the initial query. Can you check the query when fetching the order(s)?
@hlecuyer commented on GitHub (Sep 28, 2016):
Here it is. Note: I put the EAGER parameter in order to solve the problem, but it didn't change anything.
@KayKursawe commented on GitHub (Jan 22, 2020):
Any new findings on this? I'm having the same issue with doctrine/orm v2.6.1.
Seems to behave randomly somehow, running the same query several times will end up in different results.
I also checked the logs, nothing. Then I increased the php memory_limit, still no change.
What else can it be?
@SimonVanacco commented on GitHub (Aug 3, 2023):
I had this issue but it was entirely my own fault : I created a query with a join relationship and a max result directive which does not work. The docs says so here
If you have this issue check that you did not make the same mistake as me and use a Paginator istead of setMaxResult !